diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a34024..63c4dcc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,257 @@ # Changelog +## Unreleased + +> [!CAUTION] +> Like all other releases, this one was done to the best of one's ability. However, it has not been tested as thoroughly as previous releases. It is thus to be considered even more experimental than the version number already implies. + +### BC BREAK: pass conditions and sort methods through the application as specific types, instead of template parameters + +#### Old approach + +When a request is received that contains filters or sorting definitions, they are at some point (and in some form) passed to the data source, to apply them. + +Previously those definitions were immediately converted to instances supporting specific data sources, when the request was received. +The implementation of these instances depended on a factory instance provided to the request handling. + +E.g. if the data source was based on Doctrine, the application developer would choose a factory that converted the given filter into conditions that could be used for Doctrine queries. +The created conditions where then passed through the library down to the data source, where they could be directly applied. +The same was true for the sorting definitions. + +Using template parameters to type-hint the instances wherever they were passed through, allowed to ensure that static code checking tools like phpstan could detect incompatibilities between the factory chosen by the developer and the data source chosen by the developer. +However, the disadvantage was the considerable complexity overhead due to the type-hinting. + +#### New approach + +The current version changes the approach and passes a predefined format through the application. +Logic directly responsible to access the data source, receiving filter or sorting definitions, must be able to handle this predefined format to use it for that specific data source. +E.g. if the developer previously chose a condition factory compatible with his Doctrine data source, they now have to convert the predefined format to such Drupal conditions before accessing Doctrine. + +Due to the flexibility required in the format (especially for filters) it is significantly more difficult to fully validate it early, which is needed for easily understandable error messages. +For now the logic evaluating the format to access the data source must throw an exception if parts of the definitions are not supported. +In future versions the logic accessing the data source may be allowed to pass validation information (like supported filter operators) up, allowing to the request handling, to validate the definitions early. + +#### Summary of resulting changes + +Beside the extensive adjustments of type-hinting within the library, the following changes were done to the developer API. + +Note that the following examples show only the migration from one of many previous possibility to one of many current possibilities. +If in doubt, you can manually verify your method/constructor usages against the corresponding docblock type-hinting, or verify it automatically using static code checkers like phpstan on the appropriate levels. + +Otherwise, you must ensure that the filter operators supported by the request handling are supported by the data source as well, as explained above, the new approach currently can not automatically verify this aspect any longer. + +#### Use different condition factory/sort method factory implementation + +`ListRequest` instances still need a `DrupalFilterParser` and `JsonApiSortingParser` instance. +However, how these instances are created needs to be adjusted. + +Instead of selecting the implementations yourself + +```php +// both implementations chosen by you +$sortMethodFactory = new \EDT\DqlQuerying\SortMethodFactories\SortMethodFactory(); +$conditionFactory = new \EDT\DqlQuerying\ConditionFactories\DqlConditionFactory(); + +$sortingTransformer = new \EDT\JsonApi\RequestHandling\JsonApiSortingParser($sortMethodFactory); +$drupalConditionFactory = new \EDT\Querying\ConditionParsers\Drupal\PredefinedDrupalConditionFactory($conditionFactory); +$filterTransformer = new \EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser( + $conditionFactory, + new \EDT\Querying\ConditionParsers\Drupal\DrupalConditionParser($drupalConditionFactory) +); +``` + +you must now use specific implementations: + +```php +// implementations required by the library +$sortMethodFactory = new \EDT\ConditionFactory\ConditionFactory(); +$conditionFactory = new \EDT\Querying\SortMethodFactories\SortMethodFactory(); + +$sortingTransformer = new \EDT\JsonApi\RequestHandling\JsonApiSortingParser($sortMethodFactory); +$drupalConditionFactory = new \EDT\Querying\ConditionParsers\Drupal\PredefinedDrupalConditionFactory($conditionFactory) +$filterTransformer = new \EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser( + $conditionFactory, + new \EDT\Querying\ConditionParsers\Drupal\DrupalConditionParser($drupalConditionFactory) +); +``` + +These specific implementations must also be used when creating conditions or sort methods to be applied to resources or entities. + +#### Remove unnecessary constructor parameters from `DefaultProcessorConfig` + +As the needed implementations for the condition factory and sort method factory are now fixed, they are no longer needed as constructor parameters in `DefaultProcessorConfig`. + +Instead of +```php +// both implementations chosen by you +$sortMethodFactory = new \EDT\DqlQuerying\SortMethodFactories\SortMethodFactory(); +$conditionFactory = new \EDT\DqlQuerying\ConditionFactories\DqlConditionFactory(); + +$defaultProcessorConfig = new \EDT\JsonApi\Requests\DefaultProcessorConfig( + $validator, + $eventDispatcher, + $router, + $conditionFactory, + $sortMethodFactory +); +``` + +simply use + +```php +new \EDT\JsonApi\Requests\DefaultProcessorConfig( + $validator, + $eventDispatcher, + $router +); +``` + +#### Remove unnecessary interfaces + +The interfaces `PathsBasedConditionFactoryInterface` and `PathsBasedConditionGroupFactoryInterface` were removed. If you implemented any of them directly, you can simply replace the parent with `ConditionFactoryInterface` or `ConditionGroupFactoryInterface` respectively. + +#### Apply conversion logic where necessary + +This affects the classes closest to the data source. +As they now receive the predefined condition and sort method types, these must be converted to types usable for the data source. + +##### 1. `OffsetEntityProviderInterface` + +`OffsetEntityProviderInterface` is still generic (i.e. takes the type of conditions and sort methods as template parameters) and its implementations (`PrefilledEntityProvider` and `DoctrineOrmEntityProvider`) are still bound to specific types of conditions and sort methods. +I.e. `PrefilledEntityProvider` expects instances of `FunctionInterface` and `SortMethodInterface`, which can be applied on PHP objects without additional data source like a DBMS. +Likewise, `DoctrineOrmEntityProvider` expects instances of `ClauseInterface` and `OrderByInterface`, which it uses to create Doctrine queries. + +This means that you can *not* call those two provider classes with the predefined definition instances. +Where you used them, you should instead use the new `MappingEntityProvider` class instead. + +```php +// your entity class +$entityClass = Book::class; +// the factory creating conditions that can be applied in your data source, e.g. Doctrine +$conditionFactory = new \EDT\DqlQuerying\ConditionFactories\DqlConditionFactory(); +// the factory creating sort methods that can be applied in your data source, e.g. Doctrine +$sortMethodFactory = new \EDT\DqlQuerying\SortMethodFactories\SortMethodFactory(); + +// create the entity provider like you did previously, e.g. one that accesses Doctrine +$queryBuilderPreparer = new \EDT\DqlQuerying\Utilities\QueryBuilderPreparer($entityClass); +$doctrineEntityProvider = new \EDT\DqlQuerying\ObjectProviders\DoctrineOrmEntityProvider( + $doctrineEntityManager, + $queryBuilderPreparer, + $entityClass +); + +// create a `MappingEntityProvider` instance that automatically converts the predefined +// conditions and sort methods into ones suited for your entity provider defined above. +$conditionConverter = \EDT\JsonApi\InputHandling\ConditionConverter::createDefault($validator, $conditionFactory); +$sortMethodConverter = \EDT\JsonApi\InputHandling\SortMethodConverter::createDefault($validator, $sortMethodFactory); +$entityProvider = new \EDT\Querying\Contracts\MappingEntityProvider( + $conditionConverter, + $sortMethodConverter, + $doctrineEntityProvider +); + +``` + +##### 2. `FluentQuery` + +Previously the type of conditions and sort methods accepted by a `FluentQuery` instance depended on the `OffsetEntityProviderInterface` it was initialized with. + +Now it only accepts the predefined condition and sort method types and consequently its constructor only accepts an `OffsetEntityProviderInterface` that has these types set as template parameters, e.g. `MappingEntityProvider`. +To re-iterate: its constructor does no longer accept `PrefilledEntityProvider` nor `DoctrineOrmEntityProvider`. + +##### 3. `RepositoryInterface` + +Similar to `FluentQuery`, the methods in `RepositoryInterface` do no longer accept any type of conditions and sort methods, but the predefined ones only. + +You will need to adjust your implementation to convert the predefined types to the ones needed by your data source. +To do so you may use `MappingEntityProvider` directly or follow the approach used in its implementation, depending on your use case. + +#### Skip unnecessary template parameters in resource configuration classes + +Property config types were affected by the removal of the condition and sort method template parameters as well. + +When manually implementing config classes, you don't need to specify these template parameters anymore. + +The following example assumes you used a data source taking `FunctionInterface` and `OrderBySortMethodInterface` as condition/sort method implementations. + +I.e. instead of + +```php +use \EDT\DqlQuerying\Contracts\OrderBySortMethodInterface; +/** + * @template-extends MagicResourceConfigBuilder,OrderBySortMethodInterface,EntityAInterface> + * + * @property-read AttributeConfigBuilderInterface,EntityAInterface> $propertyA + * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyB + * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyC + */ +class EntityAConfig extends MagicResourceConfigBuilder +``` + +simply remove the condition/sort method template parameters and use + +```php +/** + * @template-extends MagicResourceConfigBuilder + * + * @property-read AttributeConfigBuilderInterface $propertyA + * @property-read ToOneRelationshipConfigBuilderInterface $propertyB + * @property-read ToManyRelationshipConfigBuilderInterface $propertyC + */ +class EntityAConfig extends MagicResourceConfigBuilder +``` + +Also, when generating these classes the template parameters do no longer need to be set. + +Instead of + +```php +$conditionClass = ClassOrInterfaceType::fromFqcn( + FunctionInterface::class, + [NonClassOrInterfaceType::fromRawString('bool')] +); +$sortingClass = ClassOrInterfaceType::fromFqcn(OrderBySortMethodInterface::class); +$interfaceClass = ClassOrInterfaceType::fromFqcn(EntityAInterface::class); +$parentClass = ClassOrInterfaceType::fromFqcn( + MagicResourceConfigBuilder::class, + [$conditionClass, $sortingClass, $interfaceClass] +); + +new \EDT\DqlQuerying\ClassGeneration\ResourceConfigBuilderFromEntityGenerator( + $conditionClass, + $sortingClass, + $parentClass, + $traitEvaluator +); +``` + +simply use + +```php +$interfaceClass = ClassOrInterfaceType::fromFqcn(EntityAInterface::class); +$parentClass = ClassOrInterfaceType::fromFqcn( + MagicResourceConfigBuilder::class, + [$interfaceClass] +); + +new \EDT\DqlQuerying\ClassGeneration\ResourceConfigBuilderFromEntityGenerator( + $parentClass, + $traitEvaluator +); +``` + ## 0.25.0 - 2024-05-08 +> [!CAUTION] +> Like all other releases, this one was done to the best of one's ability. However, it has not been tested as thoroughly as previous releases. It is thus to be considered even more experimental than the version number already implies. + ### BC BREAK: disallow empty lists for `propertyHasAnyOfValues` and `propertyHasNotAnyOfValues` methods This affects all implementations of `ConditionFactoryInterface` as well as `ConditionDefinition`. Creating those conditions by not passing any values to check against is not only unnecessary, as the result is known even before execution, but it may also cause mistakes due to confusions. Thus, an empty list of values in no longer allowed. -To mitigate, simply check your list before calling these methods, like shown in the following example. +To migrate, simply check your list before calling these methods, like shown in the following example. ```php $condition = [] === $values @@ -136,13 +379,15 @@ In that `OpenApiDocumentBuilder` instance, you can set configurations for action After the configuration of the builder, you can call `OpenApiDocumentBuilder::buildDocument` to retrieve the `OpenApi` instance. This seemingly increased complexity is mainly the result of keeping the generation more generic, without assuming specific translation keys to exist. -Besides that, it also allows to re-usage the same instance to generate the documentation in different languages and introduces the `Manager` class as future major entry point into the library. +Besides that, it also allows to re-use the same instance to generate the documentation in different languages and introduces the `Manager` class as future major entry point into the library. -The following shows the adjustment needed to mitigate from the old approach to the new one. +The following shows the adjustment needed to migrate from the old approach to the new one. #### Old approach -Note that no distinction was possible between types available via `get` and `list`. I.e. it was not possible to expose a type for JSON:API `get` actions only, as it was not possible to expose it for JSON:API `list` actions only. If either exposure was wanted, the documentation would state the type as exposed with the other action too. +Note that no distinction was possible between types available via `get` and `list`. +I.e. it was not possible to expose a type for JSON:API `get` actions only, like it was not possible to expose it for JSON:API `list` actions only as well. +If either exposure was wanted, the documentation would state the type as exposed with the other action too. Also, the `OpenApiSchemaGenerator` implementation would simply assume specific translation keys to be available via the given translator. ```php @@ -272,7 +517,7 @@ $config->title->addConstructorBehavior( The additional `OptionalField::NO` parameter is independent of this change and explained further down below. -To mitigate to the new approach, search in your application for all usages of classes that end with `ConstructorBehaviorFactory`. +To migrate to the new approach, search in your application for all usages of classes that end with `ConstructorBehaviorFactory`. For each one, a corresponding class ending with `ConstructorBehavior` exists, providing a `createFactory` method, as shown above. ### BC BREAK: Adjust `*SetBehavior` and `*SetBehaviorFactory` class constructors to take the `OptionalField` enum instead of `bool` diff --git a/docs/initial-setup.adoc b/docs/initial-setup.adoc index ea4f37c4..42905020 100644 --- a/docs/initial-setup.adoc +++ b/docs/initial-setup.adoc @@ -37,13 +37,7 @@ public function getAction( ): Response { $manager = $this->createManager(); $getProcessor = $manager->createGetProcessor( - new \EDT\JsonApi\Requests\DefaultProcessorConfig( - $validator, - $eventDispatcher, - $router, - new DqlConditionFactory(), - new SortMethodFactory() - ) + new \EDT\JsonApi\Requests\DefaultProcessorConfig($validator, $eventDispatcher, $router) ); return $getProcessor->createResponse($request); diff --git a/docs/releasing.adoc b/docs/releasing.adoc index aa22f45c..b8b612f3 100644 --- a/docs/releasing.adoc +++ b/docs/releasing.adoc @@ -1,16 +1,20 @@ = Releasing :sectanchors: -This repository contains the code for multiple link:https://getcomposer.org/[composer] packages inside the corresponding directories in the `packages` folder. Using link:https://github.com/symplify/monorepo-builder[symplify/monorepo-builder] these packages can be released simultaneously onto link:https://packagist.org/[Packagist], which allows them to be used as dependency in applications via composer. +This Git-repository contains the code for multiple link:https://getcomposer.org/[composer] packages. +The packages that can be released are located inside the `packages` directory. +When executing the release command, each subdirectory inside the `packages` directory is configured to be released as a composer package. +Using link:https://github.com/symplify/monorepo-builder[symplify/monorepo-builder] these packages can be released simultaneously onto link:https://packagist.org/[Packagist], which allows them to be used as dependency in applications via composer. -WARNING: The final command will execute multiple steps to release all packages at once. Because of this, utmost care should be taken before executing it. +WARNING: The final command will execute multiple steps to release all packages at once. Because of this, utmost care should be taken on each of the following steps before executing it. Failing to do so may result in broken releases. The following list focuses on the process for minor releases and patch releases, which is to be used until the first stable release was done. -1. Make sure you are on the `main` branch. -2. Make sure you have the latest state using `fetch` and `pull`. +1. Make sure you are on the `main` branch. You can check via `git status`. +2. Make sure you have the latest state using `git fetch` and `git pull`. 3. Make sure your local state does not contain changes not yet pushed to the `main`, i.e. committed as well as uncommitted changes. **Even if the following steps succeed, you would automatically include these changes in the release!** +You can stash your uncommitted changes via `git stash` and retrieve them later `git stash pop`. 4. Make sure all phpunit tests are successfully running. The test suite is defined in `phpunit.xml`. If tests fail, fix the tests or the code. diff --git a/packages/access-definitions/src/Wrapping/Contracts/ResourceTypeProviderInterface.php b/packages/access-definitions/src/Wrapping/Contracts/ResourceTypeProviderInterface.php index bf6f8464..5da06ab0 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/ResourceTypeProviderInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/ResourceTypeProviderInterface.php @@ -5,19 +5,16 @@ namespace EDT\Wrapping\Contracts; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends TransferableTypeProviderInterface + * @template-extends TransferableTypeProviderInterface */ interface ResourceTypeProviderInterface extends TransferableTypeProviderInterface { /** - * @return ResourceTypeInterface + * @return ResourceTypeInterface */ public function getType(): ResourceTypeInterface; } diff --git a/packages/access-definitions/src/Wrapping/Contracts/TransferableTypeProviderInterface.php b/packages/access-definitions/src/Wrapping/Contracts/TransferableTypeProviderInterface.php index 7d1f3cbb..dde760be 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/TransferableTypeProviderInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/TransferableTypeProviderInterface.php @@ -4,18 +4,15 @@ namespace EDT\Wrapping\Contracts; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ interface TransferableTypeProviderInterface { /** - * @return TransferableTypeInterface + * @return TransferableTypeInterface */ public function getType(): TransferableTypeInterface; } diff --git a/packages/access-definitions/src/Wrapping/Contracts/TypeProviderInterface.php b/packages/access-definitions/src/Wrapping/Contracts/TypeProviderInterface.php index e33762b2..c096769d 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/TypeProviderInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/TypeProviderInterface.php @@ -5,13 +5,9 @@ namespace EDT\Wrapping\Contracts; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** * Returns {@link EntityBasedInterface} instances for given Type identifiers. - * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface */ interface TypeProviderInterface { diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/FetchableTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/FetchableTypeInterface.php index b057d445..a33f42bf 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/FetchableTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/FetchableTypeInterface.php @@ -4,13 +4,12 @@ namespace EDT\Wrapping\Contracts\Types; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\Querying\Pagination\PagePagination; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use Pagerfanta\Pagerfanta; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ interface FetchableTypeInterface @@ -25,8 +24,8 @@ interface FetchableTypeInterface * The given conditions and sort methods must only use properties that are allowed to be used * by an external request. * - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * * @return list */ @@ -42,8 +41,8 @@ public function getEntities(array $conditions, array $sortMethods): array; * The given conditions and sort methods must only use properties that are allowed to be used * by an external request. * - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * * @return Pagerfanta */ diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/FilterableTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/FilterableTypeInterface.php index d5297dd5..f52efda9 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/FilterableTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/FilterableTypeInterface.php @@ -4,11 +4,10 @@ namespace EDT\Wrapping\Contracts\Types; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; use Exception; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object */ interface FilterableTypeInterface @@ -23,7 +22,7 @@ interface FilterableTypeInterface * imposed by the implementation. * * @param TEntity $entity - * @param list $conditions + * @param list $conditions * * @throws Exception */ @@ -39,7 +38,7 @@ public function assertMatchingEntity(object $entity, array $conditions): void; * imposed by the implementation. * * @param TEntity $entity - * @param list $conditions + * @param list $conditions */ public function isMatchingEntity(object $entity, array $conditions): bool; } diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/FilteringTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/FilteringTypeInterface.php index 694de6f7..6d216341 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/FilteringTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/FilteringTypeInterface.php @@ -4,7 +4,6 @@ namespace EDT\Wrapping\Contracts\Types; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; /** diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/PropertyReadableTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/PropertyReadableTypeInterface.php index 5db14877..f1a61a3b 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/PropertyReadableTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/PropertyReadableTypeInterface.php @@ -4,12 +4,9 @@ namespace EDT\Wrapping\Contracts\Types; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\ResourceBehavior\ResourceReadability; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ interface PropertyReadableTypeInterface @@ -19,7 +16,7 @@ interface PropertyReadableTypeInterface * * The return may depend on the current state of the application and thus may change on consecutive calls. * - * @return ResourceReadability + * @return ResourceReadability */ public function getReadability(): ResourceReadability; } diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/PropertyUpdatableTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/PropertyUpdatableTypeInterface.php index 9892ef81..04468a97 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/PropertyUpdatableTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/PropertyUpdatableTypeInterface.php @@ -4,12 +4,9 @@ namespace EDT\Wrapping\Contracts\Types; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\ResourceBehavior\ResourceUpdatability; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ interface PropertyUpdatableTypeInterface @@ -23,7 +20,7 @@ interface PropertyUpdatableTypeInterface * * Hint: You can merge the returned nested arrays via `array_merge(...$type->getUpdatableProperties())`. * - * @return ResourceUpdatability + * @return ResourceUpdatability */ public function getUpdatability(): ResourceUpdatability; } diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/ReindexableTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/ReindexableTypeInterface.php index 9f2bc02f..21d9bb63 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/ReindexableTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/ReindexableTypeInterface.php @@ -4,14 +4,13 @@ namespace EDT\Wrapping\Contracts\Types; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends FilterableTypeInterface + * @template-extends FilterableTypeInterface */ interface ReindexableTypeInterface extends FilterableTypeInterface { @@ -21,8 +20,8 @@ interface ReindexableTypeInterface extends FilterableTypeInterface * the internal default sort method setting. * * @param list $entities - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * * @return list */ diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/RelationshipFetchableTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/RelationshipFetchableTypeInterface.php index 83f6fbba..9d1b333e 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/RelationshipFetchableTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/RelationshipFetchableTypeInterface.php @@ -4,11 +4,10 @@ namespace EDT\Wrapping\Contracts\Types; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ interface RelationshipFetchableTypeInterface @@ -24,8 +23,8 @@ interface RelationshipFetchableTypeInterface * supported if they are not present in the entity. * * @param non-empty-list $identifiers - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * * @return list */ @@ -37,7 +36,7 @@ public function getEntitiesForRelationship(array $identifiers, array $conditions * Implementations are responsible to not return instances with restricted accessibility. * * @param non-empty-string $identifier - * @param list $conditions will be given full access to the properties of the entity + * @param list $conditions will be given full access to the properties of the entity * * @return TEntity */ diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/SortingTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/SortingTypeInterface.php index fba1fd7d..b4fcc79a 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/SortingTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/SortingTypeInterface.php @@ -4,13 +4,8 @@ namespace EDT\Wrapping\Contracts\Types; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ interface SortingTypeInterface { /** diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/TransferableTypeInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/TransferableTypeInterface.php index 21c7b47d..1dec6893 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/TransferableTypeInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/TransferableTypeInterface.php @@ -5,19 +5,16 @@ namespace EDT\Wrapping\Contracts\Types; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends RelationshipFetchableTypeInterface + * @template-extends RelationshipFetchableTypeInterface * @template-extends EntityBasedInterface - * @template-extends PropertyUpdatableTypeInterface - * @template-extends PropertyReadableTypeInterface - * @template-extends ReindexableTypeInterface - * @template-extends UpdatableInterface + * @template-extends PropertyUpdatableTypeInterface + * @template-extends PropertyReadableTypeInterface + * @template-extends ReindexableTypeInterface + * @template-extends UpdatableInterface */ interface TransferableTypeInterface extends NamedTypeInterface, diff --git a/packages/access-definitions/src/Wrapping/Contracts/Types/UpdatableInterface.php b/packages/access-definitions/src/Wrapping/Contracts/Types/UpdatableInterface.php index 60b1474c..f78ee23d 100644 --- a/packages/access-definitions/src/Wrapping/Contracts/Types/UpdatableInterface.php +++ b/packages/access-definitions/src/Wrapping/Contracts/Types/UpdatableInterface.php @@ -6,11 +6,9 @@ use EDT\JsonApi\RequestHandling\ExpectedPropertyCollectionInterface; use EDT\JsonApi\RequestHandling\ModifiedEntity; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\EntityDataInterface; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object */ interface UpdatableInterface diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/AbstractAttributeSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/AbstractAttributeSetBehavior.php index 84d2816a..83ae0875 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/AbstractAttributeSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/AbstractAttributeSetBehavior.php @@ -5,17 +5,15 @@ namespace EDT\Wrapping\PropertyBehavior\Attribute; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\EntityDataInterface; use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\AbstractPropertySetBehavior; use Exception; use function array_key_exists; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-extends AbstractPropertySetBehavior + * @template-extends AbstractPropertySetBehavior */ abstract class AbstractAttributeSetBehavior extends AbstractPropertySetBehavior { diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/CallbackAttributeSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/CallbackAttributeSetBehavior.php index 17b4de77..6523da6a 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/CallbackAttributeSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/CallbackAttributeSetBehavior.php @@ -4,15 +4,14 @@ namespace EDT\Wrapping\PropertyBehavior\Attribute; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\Attribute\Factory\CallbackAttributeSetBehaviorFactory; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-extends AbstractAttributeSetBehavior + * @template-extends AbstractAttributeSetBehavior */ class CallbackAttributeSetBehavior extends AbstractAttributeSetBehavior { @@ -20,7 +19,7 @@ class CallbackAttributeSetBehavior extends AbstractAttributeSetBehavior /** * @param non-empty-string $propertyName the exposed resource property name - * @param list $entityConditions + * @param list $entityConditions * @param callable(TEntity, simple_primitive|array|null): list $setterCallback */ public function __construct( @@ -33,13 +32,12 @@ public function __construct( } /** - * @template TCond of PathsBasedInterface * @template TEnt of object * - * @param list $entityConditions + * @param list $entityConditions * @param callable(TEnt, simple_primitive|array|null): list $updateCallback * - * @return CallbackAttributeSetBehaviorFactory + * @return CallbackAttributeSetBehaviorFactory */ public static function createFactory(array $entityConditions, mixed $updateCallback, OptionalField $optional): CallbackAttributeSetBehaviorFactory { diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/Factory/CallbackAttributeSetBehaviorFactory.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/Factory/CallbackAttributeSetBehaviorFactory.php index 2094718e..f7bd5ce4 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/Factory/CallbackAttributeSetBehaviorFactory.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/Factory/CallbackAttributeSetBehaviorFactory.php @@ -4,22 +4,21 @@ namespace EDT\Wrapping\PropertyBehavior\Attribute\Factory; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\Attribute\CallbackAttributeSetBehavior; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityFactoryInterface; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-implements PropertyUpdatabilityFactoryInterface + * @template-implements PropertyUpdatabilityFactoryInterface */ class CallbackAttributeSetBehaviorFactory implements PropertyUpdatabilityFactoryInterface { /** - * @param list $entityConditions + * @param list $entityConditions * @param callable(TEntity, simple_primitive|array|null): list $updateCallback */ public function __construct( diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/Factory/PathAttributeSetBehaviorFactory.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/Factory/PathAttributeSetBehaviorFactory.php index d2fe0777..d6a63f99 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/Factory/PathAttributeSetBehaviorFactory.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/Factory/PathAttributeSetBehaviorFactory.php @@ -4,23 +4,22 @@ namespace EDT\Wrapping\PropertyBehavior\Attribute\Factory; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\PropertyBehavior\Attribute\PathAttributeSetBehavior; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityFactoryInterface; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-implements PropertyUpdatabilityFactoryInterface + * @template-implements PropertyUpdatabilityFactoryInterface */ class PathAttributeSetBehaviorFactory implements PropertyUpdatabilityFactoryInterface { /** - * @param list $entityConditions + * @param list $entityConditions */ public function __construct( protected readonly PropertyAccessorInterface $propertyAccessor, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/PathAttributeSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/PathAttributeSetBehavior.php index 5faeac81..49767486 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/PathAttributeSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Attribute/PathAttributeSetBehavior.php @@ -4,17 +4,16 @@ namespace EDT\Wrapping\PropertyBehavior\Attribute; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\PropertyBehavior\Attribute\Factory\PathAttributeSetBehaviorFactory; use Webmozart\Assert\Assert; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-extends AbstractAttributeSetBehavior + * @template-extends AbstractAttributeSetBehavior */ class PathAttributeSetBehavior extends AbstractAttributeSetBehavior { @@ -23,7 +22,7 @@ class PathAttributeSetBehavior extends AbstractAttributeSetBehavior /** * @param non-empty-string $propertyName * @param class-string $entityClass - * @param list $entityConditions + * @param list $entityConditions * @param non-empty-list $propertyPath */ public function __construct( @@ -38,11 +37,9 @@ public function __construct( } /** - * @template TCond of PathsBasedInterface + * @param list $entityConditions * - * @param list $entityConditions - * - * @return PathAttributeSetBehaviorFactory + * @return PathAttributeSetBehaviorFactory */ public static function createFactory( PropertyAccessorInterface $propertyAccessor, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Identifier/PathIdentifierPostConstructorBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Identifier/PathIdentifierPostConstructorBehavior.php index e6358d5b..531858bc 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Identifier/PathIdentifierPostConstructorBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Identifier/PathIdentifierPostConstructorBehavior.php @@ -4,8 +4,8 @@ namespace EDT\Wrapping\PropertyBehavior\Identifier; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\CreationDataInterface; @@ -20,18 +20,17 @@ * * The means of setting the identifier are provided to instances via a {@link PropertyAccessorInterface}. * - * @template TCondition of PathsBasedInterface * @template TEntity of object * * @template-implements IdentifierPostConstructorBehaviorInterface - * @template-extends AbstractPropertySetBehavior + * @template-extends AbstractPropertySetBehavior */ class PathIdentifierPostConstructorBehavior extends AbstractPropertySetBehavior implements IdentifierPostConstructorBehaviorInterface { /** * @param class-string $entityClass * @param non-empty-list $propertyPath - * @param list $entityConditions + * @param list $entityConditions */ public function __construct( protected readonly string $entityClass, @@ -44,7 +43,7 @@ public function __construct( } /** - * @param list $entityConditions + * @param list $entityConditions * * @return IdentifierPostConstructorBehaviorFactoryInterface */ @@ -52,7 +51,7 @@ public static function createFactory(OptionalField $optional, PropertyAccessorIn { return new class($optional, $propertyAccessor, $entityConditions) implements IdentifierPostConstructorBehaviorFactoryInterface { /** - * @param list $entityConditions + * @param list $entityConditions */ public function __construct( protected readonly OptionalField $optional, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdatabilityFactoryInterface.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdatabilityFactoryInterface.php index 39c1f56c..f72f8353 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdatabilityFactoryInterface.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdatabilityFactoryInterface.php @@ -4,12 +4,9 @@ namespace EDT\Wrapping\PropertyBehavior; -use EDT\Querying\Contracts\PathsBasedInterface; - /** - * TODO: when TCondition is removed, move the child implementations into the `createFactory` method of the corresponding behavior implementation if possible, to reduce the amount of boilerplate classes + * TODO: move the child implementations into the `createFactory` method of the corresponding behavior implementation if possible, to reduce the amount of boilerplate classes * - * @template TCondition of PathsBasedInterface * @template TEntity of object */ interface PropertyUpdatabilityFactoryInterface @@ -19,7 +16,7 @@ interface PropertyUpdatabilityFactoryInterface * @param non-empty-list $propertyPath * @param class-string $entityClass * - * @return PropertyUpdatabilityInterface + * @return PropertyUpdatabilityInterface */ public function __invoke(string $name, array $propertyPath, string $entityClass): PropertyUpdatabilityInterface; @@ -28,7 +25,7 @@ public function __invoke(string $name, array $propertyPath, string $entityClass) * @param non-empty-list $propertyPath * @param class-string $entityClass * - * @return PropertyUpdatabilityInterface + * @return PropertyUpdatabilityInterface * * @deprecated call instance directly as callable instead (i.e. indirectly using {@link __invoke}) */ diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdatabilityInterface.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdatabilityInterface.php index cfd1f5ed..ff0d63e2 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdatabilityInterface.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdatabilityInterface.php @@ -3,11 +3,10 @@ declare(strict_types=1); namespace EDT\Wrapping\PropertyBehavior; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\Wrapping\EntityDataInterface; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * * @template-extends PropertySetBehaviorInterface @@ -21,7 +20,7 @@ interface PropertyUpdatabilityInterface extends PropertySetBehaviorInterface * * The conditions are allowed to access any properties of the entity without restrictions. * - * @return list + * @return list */ public function getEntityConditions(EntityDataInterface $entityData): array; } diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdaterTrait.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdaterTrait.php index 30cdb37f..c510de80 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdaterTrait.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/PropertyUpdaterTrait.php @@ -4,7 +4,7 @@ namespace EDT\Wrapping\PropertyBehavior; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\Contracts\Types\NamedTypeInterface; use EDT\Wrapping\Contracts\Types\RelationshipFetchableTypeInterface; @@ -15,11 +15,9 @@ trait PropertyUpdaterTrait { /** * @template TRel of object - * @template TCond of PathsBasedInterface - * @template TSort of PathsBasedInterface * - * @param NamedTypeInterface&RelationshipFetchableTypeInterface $relationshipType - * @param list $relationshipConditions + * @param NamedTypeInterface&RelationshipFetchableTypeInterface $relationshipType + * @param list $relationshipConditions * @param JsonApiRelationship|null $relationshipRef * * @return TRel|null @@ -44,11 +42,9 @@ protected function determineToOneRelationshipValue( /** * @template TRel of object - * @template TCond of PathsBasedInterface - * @template TSort of PathsBasedInterface * - * @param NamedTypeInterface&RelationshipFetchableTypeInterface $relationshipType - * @param list $relationshipConditions + * @param NamedTypeInterface&RelationshipFetchableTypeInterface $relationshipType + * @param list $relationshipConditions * @param list $relationshipRefs * * @return list diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/AbstractRelationshipSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/AbstractRelationshipSetBehavior.php index c16fde7d..31f6daaf 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/AbstractRelationshipSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/AbstractRelationshipSetBehavior.php @@ -4,27 +4,25 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\AbstractPropertySetBehavior; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends AbstractPropertySetBehavior - * @template-implements RelationshipSetBehaviorInterface + * @template-extends AbstractPropertySetBehavior + * @template-implements RelationshipSetBehaviorInterface */ abstract class AbstractRelationshipSetBehavior extends AbstractPropertySetBehavior implements RelationshipSetBehaviorInterface { /** * @param non-empty-string $propertyName - * @param list $entityConditions - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $entityConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType */ public function __construct( string $propertyName, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipConstructorBehaviorFactoryInterface.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipConstructorBehaviorFactoryInterface.php index 03d6acf4..fc1678cd 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipConstructorBehaviorFactoryInterface.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipConstructorBehaviorFactoryInterface.php @@ -5,20 +5,16 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; -/** - * @template TCondition of PathsBasedInterface - */ interface RelationshipConstructorBehaviorFactoryInterface { /** * @param non-empty-string $name * @param non-empty-list $propertyPath * @param class-string $entityClass - * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType + * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType */ public function __invoke(string $name, array $propertyPath, string $entityClass, ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType): ConstructorBehaviorInterface; @@ -26,7 +22,7 @@ public function __invoke(string $name, array $propertyPath, string $entityClass, * @param non-empty-string $name * @param non-empty-list $propertyPath * @param class-string $entityClass - * @param ResourceTypeInterface $relationshipType + * @param ResourceTypeInterface $relationshipType * * @deprecated call instance directly as callable instead (i.e. indirectly using {@link __invoke}) */ diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipSetBehaviorFactoryInterface.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipSetBehaviorFactoryInterface.php index ed82a057..49466564 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipSetBehaviorFactoryInterface.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipSetBehaviorFactoryInterface.php @@ -5,13 +5,10 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object */ @@ -21,9 +18,9 @@ interface RelationshipSetBehaviorFactoryInterface * @param non-empty-string $name * @param non-empty-list $propertyPath * @param class-string $entityClass - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType * - * @return RelationshipSetBehaviorInterface + * @return RelationshipSetBehaviorInterface */ public function __invoke(string $name, array $propertyPath, string $entityClass, TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType): RelationshipSetBehaviorInterface; @@ -31,9 +28,9 @@ public function __invoke(string $name, array $propertyPath, string $entityClass, * @param non-empty-string $name * @param non-empty-list $propertyPath * @param class-string $entityClass - * @param ResourceTypeInterface $relationshipType + * @param ResourceTypeInterface $relationshipType * - * @return RelationshipSetBehaviorInterface + * @return RelationshipSetBehaviorInterface * * @deprecated call instance directly as callable instead (i.e. indirectly using {@link __invoke}) */ diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipSetBehaviorInterface.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipSetBehaviorInterface.php index 8dcfb8a6..2f52c491 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipSetBehaviorInterface.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RelationshipSetBehaviorInterface.php @@ -4,7 +4,6 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\RelationshipInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; @@ -12,13 +11,11 @@ /** * Provides updatability information and behavior for a to-many relationship property. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends PropertyUpdatabilityInterface - * @template-extends RelationshipInterface> + * @template-extends PropertyUpdatabilityInterface + * @template-extends RelationshipInterface> */ interface RelationshipSetBehaviorInterface extends PropertyUpdatabilityInterface, RelationshipInterface { diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RequiredRelationshipConstructorBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RequiredRelationshipConstructorBehavior.php index a5db51a7..ee44c5a5 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RequiredRelationshipConstructorBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/RequiredRelationshipConstructorBehavior.php @@ -6,7 +6,6 @@ use EDT\JsonApi\ApiDocumentation\Cardinality; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; use EDT\Wrapping\Contracts\Types\NamedTypeInterface; use EDT\Wrapping\CreationDataInterface; @@ -15,8 +14,6 @@ /** * This behavior will always trigger on creation requests, regardless of the properties present in the request. - * - * @template TCondition of PathsBasedInterface */ class RequiredRelationshipConstructorBehavior implements ConstructorBehaviorInterface { @@ -25,7 +22,7 @@ class RequiredRelationshipConstructorBehavior implements ConstructorBehaviorInte /** * @param non-empty-string $argumentName * @param callable(CreationDataInterface): array{mixed, list} $callback - * @param NamedTypeInterface|ResourceTypeProviderInterface $relationshipType + * @param NamedTypeInterface|ResourceTypeProviderInterface $relationshipType */ public function __construct( protected readonly string $argumentName, @@ -36,8 +33,6 @@ public function __construct( /** * @param callable(CreationDataInterface): array{mixed, list} $behavior - * - * @return RelationshipConstructorBehaviorFactoryInterface */ public static function createFactory(callable $behavior): RelationshipConstructorBehaviorFactoryInterface { diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/AbstractPropertySetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/AbstractPropertySetBehavior.php index 2712504f..9fe6b010 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/AbstractPropertySetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/AbstractPropertySetBehavior.php @@ -4,8 +4,8 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\EntityDataInterface; use EDT\Wrapping\PropertyBehavior\IdUnrelatedTrait; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; @@ -13,10 +13,9 @@ use InvalidArgumentException; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-implements PropertyUpdatabilityInterface + * @template-implements PropertyUpdatabilityInterface */ abstract class AbstractPropertySetBehavior implements PropertyUpdatabilityInterface { @@ -25,7 +24,7 @@ abstract class AbstractPropertySetBehavior implements PropertyUpdatabilityInterf /** * @param non-empty-string $propertyName the exposed property name accepted by this instance - * @param list $entityConditions + * @param list $entityConditions */ public function __construct( protected readonly string $propertyName, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/AbstractToManyRelationshipSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/AbstractToManyRelationshipSetBehavior.php index 3ada441b..ce4afafd 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/AbstractToManyRelationshipSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/AbstractToManyRelationshipSetBehavior.php @@ -4,8 +4,8 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\EntityDataInterface; @@ -14,20 +14,18 @@ use function array_key_exists; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends AbstractRelationshipSetBehavior + * @template-extends AbstractRelationshipSetBehavior */ abstract class AbstractToManyRelationshipSetBehavior extends AbstractRelationshipSetBehavior { /** * @param non-empty-string $propertyName - * @param list $entityConditions - * @param list $relationshipConditions - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $entityConditions + * @param list $relationshipConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType */ public function __construct( string $propertyName, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/CallbackToManyRelationshipReadability.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/CallbackToManyRelationshipReadability.php index ea4ffc95..b7f0ec02 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/CallbackToManyRelationshipReadability.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/CallbackToManyRelationshipReadability.php @@ -4,18 +4,15 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\EntityVerificationTrait; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements ToManyRelationshipReadabilityInterface> + * @template-implements ToManyRelationshipReadabilityInterface> */ class CallbackToManyRelationshipReadability implements ToManyRelationshipReadabilityInterface { @@ -23,7 +20,7 @@ class CallbackToManyRelationshipReadability implements ToManyRelationshipReadabi /** * @param callable(TEntity): iterable $readCallback - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType */ public function __construct( protected readonly bool $defaultField, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/CallbackToManyRelationshipSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/CallbackToManyRelationshipSetBehavior.php index 604baa68..78ab72b1 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/CallbackToManyRelationshipSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/CallbackToManyRelationshipSetBehavior.php @@ -4,28 +4,26 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipSetBehaviorFactoryInterface; use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\Factory\CallbackToManyRelationshipSetBehaviorFactory; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends AbstractToManyRelationshipSetBehavior + * @template-extends AbstractToManyRelationshipSetBehavior */ class CallbackToManyRelationshipSetBehavior extends AbstractToManyRelationshipSetBehavior { /** * @param non-empty-string $propertyName the exposed property name accepted by this instance - * @param list $entityConditions - * @param list $relationshipConditions - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $entityConditions + * @param list $relationshipConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType * @param callable(TEntity, list): list $setterCallback */ public function __construct( @@ -40,15 +38,14 @@ public function __construct( } /** - * @template TCond of PathsBasedInterface * @template TEnt of object * @template TRel of object * * @param callable(TEnt, list): list $setBehaviorCallback - * @param list $relationshipConditions - * @param list $entityConditions + * @param list $relationshipConditions + * @param list $entityConditions * - * @return RelationshipSetBehaviorFactoryInterface + * @return RelationshipSetBehaviorFactoryInterface */ public static function createFactory( callable $setBehaviorCallback, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/Factory/CallbackToManyRelationshipSetBehaviorFactory.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/Factory/CallbackToManyRelationshipSetBehaviorFactory.php index 0fa2a4ba..04fb8baa 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/Factory/CallbackToManyRelationshipSetBehaviorFactory.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/Factory/CallbackToManyRelationshipSetBehaviorFactory.php @@ -4,9 +4,9 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany\Factory; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipSetBehaviorFactoryInterface; @@ -16,9 +16,8 @@ /** * @template TEntity of object * @template TRelationship of object - * @template TCondition of PathsBasedInterface * - * @template-implements RelationshipSetBehaviorFactoryInterface + * @template-implements RelationshipSetBehaviorFactoryInterface */ class CallbackToManyRelationshipSetBehaviorFactory implements RelationshipSetBehaviorFactoryInterface { @@ -29,8 +28,8 @@ class CallbackToManyRelationshipSetBehaviorFactory implements RelationshipSetBeh /** * @param callable(TEntity, list): list $setBehaviorCallback - * @param list $relationshipConditions - * @param list $entityConditions + * @param list $relationshipConditions + * @param list $entityConditions */ public function __construct( callable $setBehaviorCallback, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/Factory/PathToManyRelationshipSetBehaviorFactory.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/Factory/PathToManyRelationshipSetBehaviorFactory.php index 3a3fe6ea..cd634a16 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/Factory/PathToManyRelationshipSetBehaviorFactory.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/Factory/PathToManyRelationshipSetBehaviorFactory.php @@ -4,9 +4,9 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany\Factory; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; @@ -15,18 +15,16 @@ use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\PathToManyRelationshipSetBehavior; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements RelationshipSetBehaviorFactoryInterface + * @template-implements RelationshipSetBehaviorFactoryInterface */ class PathToManyRelationshipSetBehaviorFactory implements RelationshipSetBehaviorFactoryInterface { /** - * @param list $relationshipConditions - * @param list $entityConditions + * @param list $relationshipConditions + * @param list $entityConditions */ public function __construct( protected readonly array $relationshipConditions, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipReadability.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipReadability.php index 863d81c8..20a6770c 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipReadability.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipReadability.php @@ -4,19 +4,16 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\EntityVerificationTrait; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements ToManyRelationshipReadabilityInterface> + * @template-implements ToManyRelationshipReadabilityInterface> */ class PathToManyRelationshipReadability implements ToManyRelationshipReadabilityInterface { @@ -24,7 +21,7 @@ class PathToManyRelationshipReadability implements ToManyRelationshipReadability /** * @param class-string $entityClass * @param non-empty-list $propertyPath - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType */ public function __construct( protected readonly string $entityClass, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipSetBehavior.php index cab406b6..1249b3bd 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipSetBehavior.php @@ -4,8 +4,8 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; @@ -14,21 +14,19 @@ use Webmozart\Assert\Assert; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends AbstractToManyRelationshipSetBehavior + * @template-extends AbstractToManyRelationshipSetBehavior */ class PathToManyRelationshipSetBehavior extends AbstractToManyRelationshipSetBehavior { /** * @param non-empty-string $propertyName * @param class-string $entityClass - * @param list $entityConditions - * @param list $relationshipConditions - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $entityConditions + * @param list $relationshipConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType * @param non-empty-list $propertyPath */ public function __construct( @@ -45,12 +43,10 @@ public function __construct( } /** - * @template TCond of PathsBasedInterface + * @param list $relationshipConditions + * @param list $entityConditions * - * @param list $relationshipConditions - * @param list $entityConditions - * - * @return RelationshipSetBehaviorFactoryInterface + * @return RelationshipSetBehaviorFactoryInterface */ public static function createFactory( array $relationshipConditions, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipConstructorBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipConstructorBehavior.php index 4539e07f..bc82bf29 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipConstructorBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipConstructorBehavior.php @@ -4,9 +4,9 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\RelationshipInterface; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; @@ -19,10 +19,7 @@ use function array_key_exists; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - * - * @template-implements RelationshipInterface> + * @template-implements RelationshipInterface> */ class ToManyRelationshipConstructorBehavior extends AbstractConstructorBehavior implements RelationshipInterface { @@ -33,8 +30,8 @@ class ToManyRelationshipConstructorBehavior extends AbstractConstructorBehavior * * @param non-empty-string $argumentName * @param non-empty-string $propertyName - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType - * @param list $relationshipConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $relationshipConditions * @param null|callable(CreationDataInterface): array{mixed, list} $customBehavior */ public function __construct( @@ -49,13 +46,9 @@ public function __construct( } /** - * @template TCond of PathsBasedInterface - * * @param non-empty-string|null $argumentName will fall back to the property name if `null` - * @param list $relationshipConditions + * @param list $relationshipConditions * @param null|callable(CreationDataInterface): array{mixed, list} $customBehavior - * - * @return RelationshipConstructorBehaviorFactoryInterface */ public static function createFactory( ?string $argumentName, @@ -66,7 +59,7 @@ public static function createFactory( return new class($argumentName, $relationshipConditions, $customBehavior, $optional) implements RelationshipConstructorBehaviorFactoryInterface { /** * @param non-empty-string|null $argumentName will fall back to the property name if `null` - * @param list $relationshipConditions + * @param list $relationshipConditions * @param null|callable(CreationDataInterface): array{mixed, list} $customBehavior */ public function __construct( diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipReadabilityInterface.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipReadabilityInterface.php index 38420605..ac727af3 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipReadabilityInterface.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipReadabilityInterface.php @@ -4,7 +4,8 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipReadabilityInterface; use Exception; @@ -12,12 +13,10 @@ /** * Provides readability information and behavior for a to-many relationship property. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends RelationshipReadabilityInterface> + * @template-extends RelationshipReadabilityInterface> */ interface ToManyRelationshipReadabilityInterface extends RelationshipReadabilityInterface { @@ -27,8 +26,8 @@ interface ToManyRelationshipReadabilityInterface extends RelationshipReadability * Conditions and sort methods are allowed to access any property of the entity. * * @param TEntity $entity - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * * @return list * diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipSetBehaviorFactory.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipSetBehaviorFactory.php index 89edf997..b87a945f 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipSetBehaviorFactory.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipSetBehaviorFactory.php @@ -4,9 +4,9 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToMany; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; @@ -14,20 +14,18 @@ use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipSetBehaviorInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements RelationshipSetBehaviorFactoryInterface + * @template-implements RelationshipSetBehaviorFactoryInterface * * @deprecated use {@link PathToManyRelationshipSetBehaviorFactory} instead */ class ToManyRelationshipSetBehaviorFactory implements RelationshipSetBehaviorFactoryInterface { /** - * @param list $relationshipConditions - * @param list $entityConditions + * @param list $relationshipConditions + * @param list $entityConditions */ public function __construct( protected readonly array $relationshipConditions, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/AbstractToOneRelationshipSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/AbstractToOneRelationshipSetBehavior.php index d6223254..ad42847e 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/AbstractToOneRelationshipSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/AbstractToOneRelationshipSetBehavior.php @@ -4,8 +4,8 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\EntityDataInterface; @@ -14,20 +14,18 @@ use function array_key_exists; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends AbstractRelationshipSetBehavior + * @template-extends AbstractRelationshipSetBehavior */ abstract class AbstractToOneRelationshipSetBehavior extends AbstractRelationshipSetBehavior { /** * @param non-empty-string $propertyName - * @param list $entityConditions - * @param list $relationshipConditions - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $entityConditions + * @param list $relationshipConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType */ public function __construct( string $propertyName, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/CallbackToOneRelationshipReadability.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/CallbackToOneRelationshipReadability.php index ac16d3a3..937c418b 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/CallbackToOneRelationshipReadability.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/CallbackToOneRelationshipReadability.php @@ -4,18 +4,15 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\EntityVerificationTrait; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements ToOneRelationshipReadabilityInterface + * @template-implements ToOneRelationshipReadabilityInterface */ class CallbackToOneRelationshipReadability implements ToOneRelationshipReadabilityInterface { @@ -23,7 +20,7 @@ class CallbackToOneRelationshipReadability implements ToOneRelationshipReadabili /** * @param callable(TEntity): (TRelationship|null) $readCallback - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType */ public function __construct( protected readonly bool $defaultField, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/CallbackToOneRelationshipSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/CallbackToOneRelationshipSetBehavior.php index 348f9691..c8495b3f 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/CallbackToOneRelationshipSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/CallbackToOneRelationshipSetBehavior.php @@ -4,28 +4,26 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipSetBehaviorFactoryInterface; use EDT\Wrapping\PropertyBehavior\Relationship\ToOne\Factory\CallbackToOneRelationshipSetBehaviorFactory; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends AbstractToOneRelationshipSetBehavior + * @template-extends AbstractToOneRelationshipSetBehavior */ class CallbackToOneRelationshipSetBehavior extends AbstractToOneRelationshipSetBehavior { /** * @param non-empty-string $propertyName - * @param list $entityConditions - * @param list $relationshipConditions - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $entityConditions + * @param list $relationshipConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType * @param callable(TEntity, TRelationship|null): list $setterCallback */ public function __construct( @@ -40,15 +38,14 @@ public function __construct( } /** - * @template TCond of PathsBasedInterface * @template TEnt of object * @template TRel of object * * @param callable(TEnt, TRel|null): list $setBehaviorCallback - * @param list $relationshipConditions - * @param list $entityConditions + * @param list $relationshipConditions + * @param list $entityConditions * - * @return RelationshipSetBehaviorFactoryInterface + * @return RelationshipSetBehaviorFactoryInterface */ public static function createFactory( mixed $setBehaviorCallback, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/Factory/CallbackToOneRelationshipSetBehaviorFactory.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/Factory/CallbackToOneRelationshipSetBehaviorFactory.php index 119df751..f1b083c9 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/Factory/CallbackToOneRelationshipSetBehaviorFactory.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/Factory/CallbackToOneRelationshipSetBehaviorFactory.php @@ -4,9 +4,9 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne\Factory; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipSetBehaviorFactoryInterface; @@ -16,16 +16,15 @@ /** * @template TEntity of object * @template TRelationship of object - * @template TCondition of PathsBasedInterface * - * @template-implements RelationshipSetBehaviorFactoryInterface + * @template-implements RelationshipSetBehaviorFactoryInterface */ class CallbackToOneRelationshipSetBehaviorFactory implements RelationshipSetBehaviorFactoryInterface { /** * @param callable(TEntity, TRelationship|null): list $setBehaviorCallback - * @param list $relationshipConditions - * @param list $entityConditions + * @param list $relationshipConditions + * @param list $entityConditions */ public function __construct( protected readonly mixed $setBehaviorCallback, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/Factory/PathToOneRelationshipSetBehaviorFactory.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/Factory/PathToOneRelationshipSetBehaviorFactory.php index 1c4be2f7..63f1953c 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/Factory/PathToOneRelationshipSetBehaviorFactory.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/Factory/PathToOneRelationshipSetBehaviorFactory.php @@ -4,9 +4,9 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne\Factory; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; @@ -15,18 +15,16 @@ use EDT\Wrapping\PropertyBehavior\Relationship\ToOne\PathToOneRelationshipSetBehavior; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements RelationshipSetBehaviorFactoryInterface + * @template-implements RelationshipSetBehaviorFactoryInterface */ class PathToOneRelationshipSetBehaviorFactory implements RelationshipSetBehaviorFactoryInterface { /** - * @param list $relationshipConditions - * @param list $entityConditions + * @param list $relationshipConditions + * @param list $entityConditions */ public function __construct( protected readonly array $relationshipConditions, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/PathToOneRelationshipReadability.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/PathToOneRelationshipReadability.php index ba9b5472..35db062c 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/PathToOneRelationshipReadability.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/PathToOneRelationshipReadability.php @@ -4,19 +4,16 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\EntityVerificationTrait; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements ToOneRelationshipReadabilityInterface + * @template-implements ToOneRelationshipReadabilityInterface */ class PathToOneRelationshipReadability implements ToOneRelationshipReadabilityInterface { @@ -25,7 +22,7 @@ class PathToOneRelationshipReadability implements ToOneRelationshipReadabilityIn /** * @param class-string $entityClass * @param non-empty-list $propertyPath - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType */ public function __construct( protected readonly string $entityClass, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/PathToOneRelationshipSetBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/PathToOneRelationshipSetBehavior.php index 55a4df07..cd4bf10b 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/PathToOneRelationshipSetBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/PathToOneRelationshipSetBehavior.php @@ -4,8 +4,8 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; @@ -14,21 +14,19 @@ use Webmozart\Assert\Assert; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends AbstractToOneRelationshipSetBehavior + * @template-extends AbstractToOneRelationshipSetBehavior */ class PathToOneRelationshipSetBehavior extends AbstractToOneRelationshipSetBehavior { /** * @param non-empty-string $propertyName * @param class-string $entityClass - * @param list $entityConditions - * @param list $relationshipConditions - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $entityConditions + * @param list $relationshipConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType * @param non-empty-list $propertyPath */ public function __construct( @@ -45,12 +43,10 @@ public function __construct( } /** - * @template TCond of PathsBasedInterface + * @param list $relationshipConditions + * @param list $entityConditions * - * @param list $relationshipConditions - * @param list $entityConditions - * - * @return RelationshipSetBehaviorFactoryInterface + * @return RelationshipSetBehaviorFactoryInterface */ public static function createFactory( array $relationshipConditions, diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipConstructorBehavior.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipConstructorBehavior.php index 84f422b7..a14f41d2 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipConstructorBehavior.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipConstructorBehavior.php @@ -4,9 +4,9 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\RelationshipInterface; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; use EDT\Wrapping\Contracts\TransferableTypeProviderInterface; @@ -19,10 +19,7 @@ use function array_key_exists; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - * - * @template-implements RelationshipInterface> + * @template-implements RelationshipInterface> */ class ToOneRelationshipConstructorBehavior extends AbstractConstructorBehavior implements RelationshipInterface { @@ -33,8 +30,8 @@ class ToOneRelationshipConstructorBehavior extends AbstractConstructorBehavior i * * @param non-empty-string $argumentName * @param non-empty-string $propertyName - * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType - * @param list $relationshipConditions + * @param TransferableTypeInterface|TransferableTypeProviderInterface $relationshipType + * @param list $relationshipConditions * @param null|callable(CreationDataInterface): array{mixed, list} $customBehavior */ public function __construct( @@ -49,25 +46,21 @@ public function __construct( } /** - * @template TCond of PathsBasedInterface - * * @param non-empty-string|null $argumentName - * @param list $relationshipConditions + * @param list $relationshipConditions * @param null|callable(CreationDataInterface): array{mixed, list} $customBehavior - * - * @return RelationshipConstructorBehaviorFactoryInterface */ public static function createFactory( ?string $argumentName, array $relationshipConditions, mixed $customBehavior, OptionalField $optional - ): callable { + ): RelationshipConstructorBehaviorFactoryInterface { return new class($argumentName, $relationshipConditions, $customBehavior, $optional) implements RelationshipConstructorBehaviorFactoryInterface { /** * @param non-empty-string|null $argumentName - * @param list $relationshipConditions + * @param list $relationshipConditions * @param null|callable(CreationDataInterface): array{mixed, list} $customBehavior */ public function __construct( diff --git a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipReadabilityInterface.php b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipReadabilityInterface.php index 895a92c4..f12430ad 100644 --- a/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipReadabilityInterface.php +++ b/packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipReadabilityInterface.php @@ -4,7 +4,7 @@ namespace EDT\Wrapping\PropertyBehavior\Relationship\ToOne; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipReadabilityInterface; use Exception; @@ -12,12 +12,10 @@ /** * Provides readability information and behavior for a to-one relationship property. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends RelationshipReadabilityInterface> + * @template-extends RelationshipReadabilityInterface> */ interface ToOneRelationshipReadabilityInterface extends RelationshipReadabilityInterface { @@ -30,7 +28,7 @@ interface ToOneRelationshipReadabilityInterface extends RelationshipReadabilityI * that do not match all given conditions. * * @param TEntity $entity - * @param list $conditions + * @param list $conditions * * @return TRelationship|null * diff --git a/packages/access-definitions/src/Wrapping/ResourceBehavior/ResourceReadability.php b/packages/access-definitions/src/Wrapping/ResourceBehavior/ResourceReadability.php index 4c47e95f..a9f13dca 100644 --- a/packages/access-definitions/src/Wrapping/ResourceBehavior/ResourceReadability.php +++ b/packages/access-definitions/src/Wrapping/ResourceBehavior/ResourceReadability.php @@ -4,7 +4,6 @@ namespace EDT\Wrapping\ResourceBehavior; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\PropertyBehavior\Attribute\AttributeReadabilityInterface; use EDT\Wrapping\PropertyBehavior\Identifier\IdentifierReadabilityInterface; @@ -21,16 +20,14 @@ * results for multiple calls of the same method or even weaken sanity checks, which may * have unpredictable effects. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ final class ResourceReadability { /** * @param array> $attributes - * @param array> $toOneRelationships - * @param array> $toManyRelationships + * @param array> $toOneRelationships + * @param array> $toManyRelationships * @param IdentifierReadabilityInterface $idReadability */ public function __construct( @@ -59,7 +56,7 @@ public function getAttributes(): array } /** - * @return array> + * @return array> */ public function getToOneRelationships(): array { @@ -67,7 +64,7 @@ public function getToOneRelationships(): array } /** - * @return array> + * @return array> */ public function getToManyRelationships(): array { @@ -75,7 +72,7 @@ public function getToManyRelationships(): array } /** - * @return array|ToOneRelationshipReadabilityInterface|ToManyRelationshipReadabilityInterface> + * @return array|ToOneRelationshipReadabilityInterface|ToManyRelationshipReadabilityInterface> */ public function getAllProperties(): array { @@ -87,7 +84,7 @@ public function getAllProperties(): array } /** - * @return array|ToManyRelationshipReadabilityInterface> + * @return array|ToManyRelationshipReadabilityInterface> */ public function getRelationships(): array { @@ -106,7 +103,7 @@ public function hasRelationship(string $propertyName): bool /** * @param non-empty-string $propertyName * - * @return ToOneRelationshipReadabilityInterface|ToManyRelationshipReadabilityInterface + * @return ToOneRelationshipReadabilityInterface|ToManyRelationshipReadabilityInterface * * @throws InvalidArgumentException */ @@ -133,7 +130,7 @@ public function getAttribute(string $propertyName): AttributeReadabilityInterfac /** * @param non-empty-string $propertyName * - * @return ToOneRelationshipReadabilityInterface + * @return ToOneRelationshipReadabilityInterface */ public function getToOneRelationship(string $propertyName): ToOneRelationshipReadabilityInterface { @@ -144,7 +141,7 @@ public function getToOneRelationship(string $propertyName): ToOneRelationshipRea /** * @param non-empty-string $propertyName * - * @return ToManyRelationshipReadabilityInterface + * @return ToManyRelationshipReadabilityInterface */ public function getToManyRelationship(string $propertyName): ToManyRelationshipReadabilityInterface { diff --git a/packages/access-definitions/src/Wrapping/ResourceBehavior/ResourceUpdatability.php b/packages/access-definitions/src/Wrapping/ResourceBehavior/ResourceUpdatability.php index 4fbac26e..48156d5a 100644 --- a/packages/access-definitions/src/Wrapping/ResourceBehavior/ResourceUpdatability.php +++ b/packages/access-definitions/src/Wrapping/ResourceBehavior/ResourceUpdatability.php @@ -4,8 +4,8 @@ namespace EDT\Wrapping\ResourceBehavior; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\NamedTypeInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use EDT\Wrapping\EntityDataInterface; @@ -17,17 +17,15 @@ use function array_key_exists; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class ResourceUpdatability extends AbstractResourceModifier { /** - * @param array>> $attributes - * @param array>> $toOneRelationships - * @param array>> $toManyRelationships - * @param list> $generalUpdateBehaviors + * @param array>> $attributes + * @param array>> $toOneRelationships + * @param array>> $toManyRelationships + * @param list> $generalUpdateBehaviors */ public function __construct( protected readonly array $attributes, @@ -43,7 +41,7 @@ public function __construct( /** * Get all setabilities, that correspond to the given entity data. * - * @return list> + * @return list> */ protected function getSetabilities(): array { @@ -97,7 +95,7 @@ public function updateProperties(object $entity, EntityDataInterface $entityData * Does not process any paths, as the set-behavior entity conditions are expected to * be hardcoded and not supplied via request. * - * @return list + * @return list */ public function getEntityConditions(EntityDataInterface $entityData): array { @@ -112,7 +110,7 @@ public function getEntityConditions(EntityDataInterface $entityData): array /** * @param non-empty-string $propertyName * - * @return array&NamedTypeInterface&EntityBasedInterface> + * @return array&NamedTypeInterface&EntityBasedInterface> */ public function getToOneRelationshipTypes(string $propertyName): array { @@ -125,7 +123,7 @@ public function getToOneRelationshipTypes(string $propertyName): array /** * @param non-empty-string $propertyName * - * @return array&NamedTypeInterface&EntityBasedInterface> + * @return array&NamedTypeInterface&EntityBasedInterface> */ public function getToManyRelationshipTypes(string $propertyName): array { @@ -138,9 +136,9 @@ public function getToManyRelationshipTypes(string $propertyName): array /** * @template TRelationship of object * - * @param list> $behaviors + * @param list> $behaviors * - * @return array&NamedTypeInterface&EntityBasedInterface> + * @return array&NamedTypeInterface&EntityBasedInterface> */ protected function extractRelationshipTypes(array $behaviors): array { diff --git a/packages/access-definitions/src/Wrapping/TypeProviders/LazyTypeProvider.php b/packages/access-definitions/src/Wrapping/TypeProviders/LazyTypeProvider.php index 86df605a..1986ace7 100644 --- a/packages/access-definitions/src/Wrapping/TypeProviders/LazyTypeProvider.php +++ b/packages/access-definitions/src/Wrapping/TypeProviders/LazyTypeProvider.php @@ -5,16 +5,9 @@ namespace EDT\Wrapping\TypeProviders; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TypeProviderInterface; use InvalidArgumentException; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - * - * @template-implements TypeProviderInterface - */ class LazyTypeProvider implements TypeProviderInterface { /** @@ -41,9 +34,6 @@ public function setType(string $identifier, EntityBasedInterface $type): void $this->types[$identifier] = $type; } - /** - * @param TypeProviderInterface $typeProvider - */ public function setAllTypes(TypeProviderInterface $typeProvider): void { foreach ($typeProvider->getTypeIdentifiers() as $typeIdentifier) { diff --git a/packages/access-definitions/src/Wrapping/TypeProviders/PrefilledTypeProvider.php b/packages/access-definitions/src/Wrapping/TypeProviders/PrefilledTypeProvider.php index 99f2ce26..ed959bba 100644 --- a/packages/access-definitions/src/Wrapping/TypeProviders/PrefilledTypeProvider.php +++ b/packages/access-definitions/src/Wrapping/TypeProviders/PrefilledTypeProvider.php @@ -5,7 +5,6 @@ namespace EDT\Wrapping\TypeProviders; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TypeProviderInterface; use InvalidArgumentException; use function array_key_exists; @@ -15,11 +14,6 @@ * and will assign each item an identifier using the {@link PrefilledTypeProvider::getIdentifier()} * method. By default, the fully qualified class name is chosen as identifier. To use something different * override {@link PrefilledTypeProvider::getIdentifier()}. - * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - * - * @template-implements TypeProviderInterface */ class PrefilledTypeProvider implements TypeProviderInterface { diff --git a/packages/access-definitions/src/Wrapping/Utilities/PropertyPathProcessor.php b/packages/access-definitions/src/Wrapping/Utilities/PropertyPathProcessor.php index 55ddb729..3da46216 100644 --- a/packages/access-definitions/src/Wrapping/Utilities/PropertyPathProcessor.php +++ b/packages/access-definitions/src/Wrapping/Utilities/PropertyPathProcessor.php @@ -4,10 +4,9 @@ namespace EDT\Wrapping\Utilities; +use EDT\Querying\Contracts\PathAdjustableInterface; use EDT\Querying\Contracts\PathException; use EDT\Querying\Contracts\PathsBasedInterface; -use EDT\Querying\Contracts\PropertyPathAccessInterface; -use EDT\Querying\PropertyPaths\PathInfo; use EDT\Querying\PropertyPaths\PropertyLinkInterface; use EDT\Wrapping\Contracts\AccessException; use EDT\Wrapping\Contracts\PropertyAccessException; @@ -44,23 +43,21 @@ public function __construct( * {@link AbstractProcessorConfig::getProperties()}). * @throws PathException */ - public function processPropertyPaths(PathsBasedInterface $pathsBased): void + public function processPropertyPaths(PathAdjustableInterface $pathAdjustable): void { // If the path is `book.author.name` and `author` needs mapping but `book` does not // then we get the author relationship here and map it to something like // `book.authoredBy.fullName` or `book.author.meta.name` depending on the // schema of the object class backing the type. - array_map(function (PropertyPathAccessInterface $propertyPath): void { - $path = $propertyPath->getAsNames(); + $pathAdjustable->adjustPath(function (array $path): array { $rootType = $this->processorConfig->getRootType(); try { $availableProperties = $this->processorConfig->getProperties($rootType); - $path = $this->processPropertyPath($availableProperties, [], ...$path); + return $this->processPropertyPath($availableProperties, [], ...$path); } catch (PropertyAccessException $exception) { throw AccessException::pathDenied($rootType, $exception, $path); } - $propertyPath->setPath($path); - }, PathInfo::getPropertyPaths($pathsBased)); + }); } /** diff --git a/packages/access-definitions/src/Wrapping/Utilities/SchemaPathProcessor.php b/packages/access-definitions/src/Wrapping/Utilities/SchemaPathProcessor.php index 4e1fe050..5bb3b04e 100644 --- a/packages/access-definitions/src/Wrapping/Utilities/SchemaPathProcessor.php +++ b/packages/access-definitions/src/Wrapping/Utilities/SchemaPathProcessor.php @@ -4,9 +4,10 @@ namespace EDT\Wrapping\Utilities; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\Querying\Contracts\EntityBasedInterface; use EDT\Querying\Contracts\PathException; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Wrapping\Contracts\AccessException; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\Contracts\PropertyAccessException; @@ -23,6 +24,8 @@ * Follows {@link PropertyPathAccessInterface} instances to check if access is * allowed in the context of a given root {@link EntityBasedInterface} and maps * the paths according to the corresponding configured aliases. + * + * TODO: remove this class by moving its logic into the classes where it is actually needed */ class SchemaPathProcessor { @@ -33,10 +36,8 @@ public function __construct( /** * Check the paths of the given conditions for availability and applies aliases using the given type. * - * @template TCondition of PathsBasedInterface - * * @param FilteringTypeInterface&EntityBasedInterface $type - * @param non-empty-list $conditions + * @param non-empty-list $conditions * * @throws PathException * @throws AccessException @@ -51,11 +52,7 @@ public function mapFilterConditions(FilteringTypeInterface&EntityBasedInterface /** * Check the paths of the given sort methods for availability and aliases using the given type. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - * - * @param SortingTypeInterface $type - * @param non-empty-list $sortMethods + * @param non-empty-list $sortMethods * * @throws AccessException * @throws PathException @@ -90,7 +87,7 @@ public function mapSorting(SortingTypeInterface $type, array $sortMethods): void * Note that {@link ContentField::ID} and {@link ContentField::TYPE} are not allowed in the given path, as they * are always readable. * - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * @param non-empty-list $path * * @throws PropertyAccessException diff --git a/packages/access-definitions/src/Wrapping/Utilities/TypeAccessors/ExternSortableProcessorConfig.php b/packages/access-definitions/src/Wrapping/Utilities/TypeAccessors/ExternSortableProcessorConfig.php index 01aa3ebc..ea7d9b85 100644 --- a/packages/access-definitions/src/Wrapping/Utilities/TypeAccessors/ExternSortableProcessorConfig.php +++ b/packages/access-definitions/src/Wrapping/Utilities/TypeAccessors/ExternSortableProcessorConfig.php @@ -4,11 +4,10 @@ namespace EDT\Wrapping\Utilities\TypeAccessors; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\SortingTypeInterface; /** - * @template-extends AbstractProcessorConfig> + * @template-extends AbstractProcessorConfig */ class ExternSortableProcessorConfig extends AbstractProcessorConfig { diff --git a/packages/access-definitions/src/Wrapping/WrapperFactories/WrapperArrayFactory.php b/packages/access-definitions/src/Wrapping/WrapperFactories/WrapperArrayFactory.php index 387f33d8..ca86b547 100644 --- a/packages/access-definitions/src/Wrapping/WrapperFactories/WrapperArrayFactory.php +++ b/packages/access-definitions/src/Wrapping/WrapperFactories/WrapperArrayFactory.php @@ -5,7 +5,6 @@ namespace EDT\Wrapping\WrapperFactories; use EDT\Querying\Contracts\PathException; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Querying\Contracts\SortException; use EDT\Wrapping\Contracts\AccessException; @@ -60,10 +59,7 @@ public function __construct( * wrapped using this factory until the depth set in this instance is reached. * If access is not granted it will be replaced by `null`. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - * - * @param TransferableTypeInterface $type + * @param TransferableTypeInterface $type * * @return array an array containing the readable properties of the given type * diff --git a/packages/access-definitions/src/Wrapping/WrapperFactories/WrapperObject.php b/packages/access-definitions/src/Wrapping/WrapperFactories/WrapperObject.php index d4e036aa..36329102 100644 --- a/packages/access-definitions/src/Wrapping/WrapperFactories/WrapperObject.php +++ b/packages/access-definitions/src/Wrapping/WrapperFactories/WrapperObject.php @@ -4,9 +4,10 @@ namespace EDT\Wrapping\WrapperFactories; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ResourceTypes\AbstractResourceType; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Wrapping\Contracts\AccessException; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\Contracts\PropertyAccessException; @@ -35,8 +36,6 @@ * Returned relationships will be wrapped themselves inside {@link WrapperObject} instances. * * @template TEntity of object - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface */ class WrapperObject { @@ -49,7 +48,7 @@ class WrapperObject /** * @param TEntity $entity - * @param TransferableTypeInterface $type + * @param TransferableTypeInterface $type * * @throws InvalidArgumentException */ @@ -66,7 +65,7 @@ public function __construct( } /** - * @return TransferableTypeInterface + * @return TransferableTypeInterface */ public function getResourceType(): TransferableTypeInterface { @@ -133,9 +132,9 @@ public function getAttribute(string $propertyName): mixed /** * @param non-empty-string $propertyName - * @param list $conditions + * @param list $conditions * - * @return WrapperObject|null + * @return WrapperObject|null */ public function getToOneRelationship(string $propertyName, array $conditions = []): ?WrapperObject { @@ -154,7 +153,7 @@ public function getToOneRelationship(string $propertyName, array $conditions = [ /** * @param non-empty-string $propertyName - * @param list $conditions + * @param list $conditions * * @return non-empty-string|null */ @@ -167,10 +166,10 @@ public function getToOneRelationshipReference(string $propertyName, array $condi * TODO: should returned instances automatically be sorted by {@link AbstractResourceType::getDefaultSortMethods()}? Would this conflict with {@link \Doctrine\ORM\Mapping\OrderBy}? How/where to implement? * * @param non-empty-string $propertyName - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * - * @return list> + * @return list> */ public function getToManyRelationships(string $propertyName, array $conditions = [], array $sortMethods = []): array { @@ -190,8 +189,8 @@ public function getToManyRelationships(string $propertyName, array $conditions = /** * @param non-empty-string $propertyName - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * * @return list */ @@ -260,7 +259,7 @@ public function setAttribute(string $propertyName, mixed $value): array * @template TRelationship of object * * @param non-empty-string $propertyName - * @param PropertyReadableTypeInterface&NamedTypeInterface&EntityBasedInterface $relationshipType + * @param PropertyReadableTypeInterface&NamedTypeInterface&EntityBasedInterface $relationshipType * * @return list */ @@ -283,7 +282,7 @@ public function setToOneRelationship( * * @param non-empty-string $propertyName * @param list $values - * @param PropertyReadableTypeInterface&NamedTypeInterface&EntityBasedInterface $relationshipType + * @param PropertyReadableTypeInterface&NamedTypeInterface&EntityBasedInterface $relationshipType * * @return list */ @@ -305,9 +304,9 @@ public function setToManyRelationship( /** * @template TRelationship of object * - * @param array&NamedTypeInterface&EntityBasedInterface> $relationshipTypes + * @param array&NamedTypeInterface&EntityBasedInterface> $relationshipTypes * - * @return PropertyReadableTypeInterface&NamedTypeInterface&EntityBasedInterface + * @return PropertyReadableTypeInterface&NamedTypeInterface&EntityBasedInterface */ protected function getSingleRelationshipType(array $relationshipTypes): object { @@ -319,7 +318,7 @@ protected function getSingleRelationshipType(array $relationshipTypes): object } /** - * @param ResourceUpdatability $updatability + * @param ResourceUpdatability $updatability * * @return list */ @@ -398,7 +397,7 @@ public function __set(string $propertyName, mixed $value): void } /** - * @param list $conditions + * @param list $conditions */ public function isMatchingAllConditions(array $conditions): bool { @@ -488,9 +487,9 @@ public function getEntity(): object * @template TRelationship of object * * @param TRelationship $entity - * @param TransferableTypeInterface $type + * @param TransferableTypeInterface $type * - * @return WrapperObject + * @return WrapperObject * * @throws InvalidArgumentException */ @@ -514,7 +513,7 @@ protected function createAttributeEntityData(string $propertyName, mixed $value) * * @param non-empty-string $propertyName * @param TRelationship|null $relationship - * @param PropertyReadableTypeInterface&NamedTypeInterface $relationshipType + * @param PropertyReadableTypeInterface&NamedTypeInterface $relationshipType */ protected function createToOneRelationshipEntityData( string $propertyName, @@ -536,7 +535,7 @@ protected function createToOneRelationshipEntityData( * * @param non-empty-string $propertyName * @param list $relationships - * @param PropertyReadableTypeInterface&NamedTypeInterface $relationshipType + * @param PropertyReadableTypeInterface&NamedTypeInterface $relationshipType */ protected function createToManyRelationshipEntityData( string $propertyName, diff --git a/packages/access-definitions/tests/ResourceConfig/Builder/BookBasedTypeConfig.php b/packages/access-definitions/tests/ResourceConfig/Builder/BookBasedTypeConfig.php index 3c2633b2..a1a90004 100644 --- a/packages/access-definitions/tests/ResourceConfig/Builder/BookBasedTypeConfig.php +++ b/packages/access-definitions/tests/ResourceConfig/Builder/BookBasedTypeConfig.php @@ -6,12 +6,11 @@ use EDT\JsonApi\PropertyConfig\Builder\ToOneRelationshipConfigBuilderInterface; use EDT\JsonApi\ResourceConfig\Builder\TypeConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use Tests\data\Model\Book; use Tests\data\Model\Person; /** - * @property-read ToOneRelationshipConfigBuilderInterface $author + * @property-read ToOneRelationshipConfigBuilderInterface $author */ class BookBasedTypeConfig extends TypeConfig { diff --git a/packages/access-definitions/tests/ResourceConfig/Builder/PersonBasedConfigBuilder.php b/packages/access-definitions/tests/ResourceConfig/Builder/PersonBasedConfigBuilder.php index ce965e27..b72c51d9 100644 --- a/packages/access-definitions/tests/ResourceConfig/Builder/PersonBasedConfigBuilder.php +++ b/packages/access-definitions/tests/ResourceConfig/Builder/PersonBasedConfigBuilder.php @@ -6,12 +6,11 @@ use EDT\JsonApi\PropertyConfig\Builder\ToManyRelationshipConfigBuilderInterface; use EDT\JsonApi\ResourceConfig\Builder\TypeConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use Tests\data\Model\Book; use Tests\data\Model\Person; /** - * @property-read ToManyRelationshipConfigBuilderInterface $books + * @property-read ToManyRelationshipConfigBuilderInterface $books */ class PersonBasedConfigBuilder extends TypeConfig { diff --git a/packages/access-definitions/tests/Utilities/PropertyBuilderFactoryTest.php b/packages/access-definitions/tests/Utilities/PropertyBuilderFactoryTest.php index 8bcba5ac..0930415f 100644 --- a/packages/access-definitions/tests/Utilities/PropertyBuilderFactoryTest.php +++ b/packages/access-definitions/tests/Utilities/PropertyBuilderFactoryTest.php @@ -4,17 +4,11 @@ namespace Tests\Utilities; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\JsonApi\Utilities\PropertyBuilderFactory; -use EDT\Querying\ConditionFactories\PhpConditionFactory; -use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; -use EDT\Wrapping\Contracts\TypeProviderInterface; -use EDT\Wrapping\TypeProviders\LazyTypeProvider; use PHPUnit\Framework\TestCase; use ReflectionProperty; -use Tests\data\ApiTypes\AuthorType; use Tests\data\DqlModel\Person; use Tests\data\Model\Book; diff --git a/packages/access-definitions/tests/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipReadabilityTest.php b/packages/access-definitions/tests/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipReadabilityTest.php index 1bb8e7f3..38b1869b 100644 --- a/packages/access-definitions/tests/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipReadabilityTest.php +++ b/packages/access-definitions/tests/Wrapping/PropertyBehavior/Relationship/ToMany/PathToManyRelationshipReadabilityTest.php @@ -4,6 +4,7 @@ namespace Tests\Wrapping\PropertyBehavior\Relationship\ToMany; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\Querying\ConditionFactories\PhpConditionFactory; use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; @@ -22,7 +23,7 @@ protected function setUp(): void { parent::setUp(); - $conditionFactory = new PhpConditionFactory(); + $conditionFactory = new ConditionFactory(); $lazyTypeProvider = new LazyTypeProvider(); $this->propertyAccessor = new ReflectionPropertyAccessor(); $typeResolver = new AttributeTypeResolver(); diff --git a/packages/access-definitions/tests/Wrapping/TypeProviders/PrefilledTypeProviderTest.php b/packages/access-definitions/tests/Wrapping/TypeProviders/PrefilledTypeProviderTest.php index c6135725..6445556e 100644 --- a/packages/access-definitions/tests/Wrapping/TypeProviders/PrefilledTypeProviderTest.php +++ b/packages/access-definitions/tests/Wrapping/TypeProviders/PrefilledTypeProviderTest.php @@ -4,6 +4,7 @@ namespace Tests\Wrapping\TypeProviders; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\Querying\ConditionFactories\PhpConditionFactory; use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; @@ -21,7 +22,7 @@ protected function setUp(): void { parent::setUp(); - $conditionFactory = new PhpConditionFactory(); + $conditionFactory = new ConditionFactory(); $lazyTypeProvider = new LazyTypeProvider(); $propertyAccessor = new ReflectionPropertyAccessor(); $typeResolver = new AttributeTypeResolver(); diff --git a/packages/access-definitions/tests/Wrapping/Utilities/PropertyPathProcessorTest.php b/packages/access-definitions/tests/Wrapping/Utilities/PropertyPathProcessorTest.php index e3921ec0..eae072d1 100644 --- a/packages/access-definitions/tests/Wrapping/Utilities/PropertyPathProcessorTest.php +++ b/packages/access-definitions/tests/Wrapping/Utilities/PropertyPathProcessorTest.php @@ -4,10 +4,9 @@ namespace Tests\Wrapping\Utilities; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; -use EDT\Querying\ConditionFactories\PhpConditionFactory; use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; -use EDT\Wrapping\Contracts\PropertyAccessException; use EDT\Wrapping\TypeProviders\LazyTypeProvider; use EDT\Wrapping\TypeProviders\PrefilledTypeProvider; use EDT\Wrapping\Utilities\PropertyPathProcessor; @@ -28,7 +27,7 @@ class PropertyPathProcessorTest extends TestCase protected function setUp(): void { parent::setUp(); - $conditionFactory = new PhpConditionFactory(); + $conditionFactory = new ConditionFactory(); $lazyTypeProvider = new LazyTypeProvider(); $propertyAccessor = new ReflectionPropertyAccessor(); $typeResolver = new AttributeTypeResolver(); diff --git a/packages/access-definitions/tests/Wrapping/Utilities/PropertyReaderTest.php b/packages/access-definitions/tests/Wrapping/Utilities/PropertyReaderTest.php index 6e0a8c83..f36d5d87 100644 --- a/packages/access-definitions/tests/Wrapping/Utilities/PropertyReaderTest.php +++ b/packages/access-definitions/tests/Wrapping/Utilities/PropertyReaderTest.php @@ -4,6 +4,7 @@ namespace Tests\Wrapping\Utilities; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\Querying\ConditionFactories\PhpConditionFactory; use EDT\Querying\Contracts\PropertyAccessorInterface; @@ -24,7 +25,7 @@ class PropertyReaderTest extends ModelBasedTest protected function setUp(): void { parent::setUp(); - $conditionFactory = new PhpConditionFactory(); + $conditionFactory = new ConditionFactory(); $lazyTypeProvider = new LazyTypeProvider(); $this->propertyAccessor = new ReflectionPropertyAccessor(); $typeResolver = new AttributeTypeResolver(); diff --git a/packages/access-definitions/tests/Wrapping/Utilities/SchemaPathProcessorTest.php b/packages/access-definitions/tests/Wrapping/Utilities/SchemaPathProcessorTest.php index be265815..05047856 100644 --- a/packages/access-definitions/tests/Wrapping/Utilities/SchemaPathProcessorTest.php +++ b/packages/access-definitions/tests/Wrapping/Utilities/SchemaPathProcessorTest.php @@ -4,6 +4,7 @@ namespace Tests\Wrapping\Utilities; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\Querying\ConditionFactories\PhpConditionFactory; use EDT\Querying\Contracts\PropertyPathAccessInterface; @@ -11,6 +12,9 @@ use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; use EDT\Querying\PropertyPaths\PropertyPath; use EDT\Querying\SortMethodFactories\PhpSortMethodFactory; +use EDT\Querying\SortMethodFactories\SortMethod; +use EDT\Querying\SortMethodFactories\SortMethodInterface; +use EDT\Querying\SortMethodFactories\SortMethodFactory; use EDT\Querying\SortMethods\Ascending; use EDT\Wrapping\Contracts\AccessException; use EDT\Wrapping\TypeProviders\LazyTypeProvider; @@ -30,15 +34,15 @@ class SchemaPathProcessorTest extends ModelBasedTest private AuthorType $authorType; - private PhpSortMethodFactory $sortMethodFactory; + private SortMethodFactory $sortMethodFactory; private BookType $bookType; private PrefilledTypeProvider $typeProvider; protected function setUp(): void { parent::setUp(); - $this->sortMethodFactory = new PhpSortMethodFactory(); - $conditionFactory = new PhpConditionFactory(); + $this->sortMethodFactory = new SortMethodFactory(); + $conditionFactory = new ConditionFactory(); $lazyTypeProvider = new LazyTypeProvider(); $propertyAccessor = new ReflectionPropertyAccessor(); $propertyPathProcessorFactory = new PropertyPathProcessorFactory(); @@ -65,12 +69,9 @@ public function testSortAccessException(): void public function testMapSorting(): void { $propertyPath = new PropertyPath(null, '', PropertyPathAccessInterface::UNPACK_RECURSIVE, ['name']); - $sortMethod = new Ascending(new Property($propertyPath)); + $sortMethod = new SortMethod($propertyPath->getAsNames(), false); $this->schemaPathProcessor->mapSorting($this->authorType, [$sortMethod]); - $paths = $sortMethod->getPropertyPaths(); - self::assertCount(1, $paths); - $path = array_pop($paths); - self::assertSame(['name'], $path->getPath()->getAsNames()); + self::assertSame('name', $sortMethod->getAsString()); } diff --git a/packages/access-definitions/tests/Wrapping/WrapperFactories/WrapperArrayFactoryTest.php b/packages/access-definitions/tests/Wrapping/WrapperFactories/WrapperArrayFactoryTest.php index a00e3d77..6ff73cc2 100644 --- a/packages/access-definitions/tests/Wrapping/WrapperFactories/WrapperArrayFactoryTest.php +++ b/packages/access-definitions/tests/Wrapping/WrapperFactories/WrapperArrayFactoryTest.php @@ -4,9 +4,18 @@ namespace Tests\Wrapping\WrapperFactories; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; -use EDT\Querying\ConditionFactories\PhpConditionFactory; +use EDT\JsonApi\InputHandling\PhpEntityRepository; +use EDT\JsonApi\InputHandling\RepositoryInterface; +use EDT\JsonApi\RequestHandling\JsonApiSortingParser; +use EDT\JsonApi\Validation\SortValidator; +use EDT\Querying\ConditionParsers\Drupal\DrupalConditionParser; +use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; +use EDT\Querying\ConditionParsers\Drupal\DrupalFilterValidator; +use EDT\Querying\ConditionParsers\Drupal\PredefinedDrupalConditionFactory; use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; +use EDT\Querying\SortMethodFactories\SortMethodFactory; use EDT\Querying\Utilities\ConditionEvaluator; use EDT\Querying\Utilities\Sorter; use EDT\Querying\Utilities\TableJoiner; @@ -19,6 +28,7 @@ use EDT\Wrapping\WrapperFactories\WrapperArrayFactory; use EDT\Querying\ObjectProviders\PrefilledEntityProvider; use EDT\Wrapping\TypeProviders\PrefilledTypeProvider; +use Symfony\Component\Validator\Validation; use Tests\data\AdModel\Person; use Tests\data\AdModelBasedTest; use Tests\data\Types\BirthType; @@ -30,12 +40,7 @@ class WrapperArrayFactoryTest extends AdModelBasedTest { private AuthorType $authorType; - private PhpConditionFactory $conditionFactory; - - /** - * @var PrefilledEntityProvider - */ - private PrefilledEntityProvider $authorProvider; + private ConditionFactory $conditionFactory; private PrefilledTypeProvider $typeProvider; @@ -43,10 +48,12 @@ class WrapperArrayFactoryTest extends AdModelBasedTest private SchemaPathProcessor $schemaPathProcessor; + private RepositoryInterface $authorRepository; + protected function setUp(): void { parent::setUp(); - $this->conditionFactory = new PhpConditionFactory(); + $this->conditionFactory = new ConditionFactory(); $lazyTypeProvider = new LazyTypeProvider(); $this->propertyAccessor = new ReflectionPropertyAccessor(); $typeResolver = new AttributeTypeResolver(); @@ -58,9 +65,15 @@ protected function setUp(): void new BirthType($this->conditionFactory), ]); $lazyTypeProvider->setAllTypes($this->typeProvider); - $this->authorProvider = new PrefilledEntityProvider( - new ConditionEvaluator(new TableJoiner($this->propertyAccessor)), - new Sorter(new TableJoiner($this->propertyAccessor)), + $validator = Validation::createValidator(); + $predefinedDrupalConditionFactory = new PredefinedDrupalConditionFactory($this->conditionFactory); + $filterValidator = new DrupalFilterValidator( + $validator, + $predefinedDrupalConditionFactory + ); + $this->authorRepository = PhpEntityRepository::createDefault( + $validator, + new ReflectionPropertyAccessor(), $this->authors ); $this->schemaPathProcessor = new SchemaPathProcessor(new PropertyPathProcessorFactory()); @@ -246,7 +259,7 @@ private function listEntities(FilteringTypeInterface $type, array $conditions): $this->schemaPathProcessor->mapFilterConditions($type, $conditions); $conditions = array_merge($conditions, $type->getAccessConditions()); - return $this->authorProvider->getEntities($conditions, [], null); + return $this->authorRepository->getEntities($conditions, []); } /** diff --git a/packages/access-definitions/tests/Wrapping/WrapperFactories/WrapperObjectTest.php b/packages/access-definitions/tests/Wrapping/WrapperFactories/WrapperObjectTest.php index 00fc9674..27b8929d 100644 --- a/packages/access-definitions/tests/Wrapping/WrapperFactories/WrapperObjectTest.php +++ b/packages/access-definitions/tests/Wrapping/WrapperFactories/WrapperObjectTest.php @@ -4,6 +4,7 @@ namespace Tests\Wrapping\WrapperFactories; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\Querying\ConditionFactories\PhpConditionFactory; use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; @@ -24,7 +25,7 @@ class WrapperObjectTest extends AdModelBasedTest protected function setUp(): void { parent::setUp(); - $conditionFactory = new PhpConditionFactory(); + $conditionFactory = new ConditionFactory(); $propertyAccessor = new ReflectionPropertyAccessor(); $lazyTypeProvider = new LazyTypeProvider(); $attributeTypeResolver = new AttributeTypeResolver(); diff --git a/packages/access-definitions/tests/data/Types/AuthorType.php b/packages/access-definitions/tests/data/Types/AuthorType.php index d830344f..024307ab 100644 --- a/packages/access-definitions/tests/data/Types/AuthorType.php +++ b/packages/access-definitions/tests/data/Types/AuthorType.php @@ -4,18 +4,17 @@ namespace Tests\data\Types; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; +use EDT\ConditionFactory\ConditionFactoryInterface; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\JsonApi\ApiDocumentation\OptionalField; +use EDT\JsonApi\InputHandling\PhpEntityRepository; +use EDT\JsonApi\InputHandling\RepositoryInterface; use EDT\JsonApi\RequestHandling\ExpectedPropertyCollection; use EDT\JsonApi\RequestHandling\ModifiedEntity; use EDT\Querying\Contracts\PropertyAccessorInterface; +use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; use EDT\Querying\PropertyPaths\NonRelationshipLink; use EDT\Querying\PropertyPaths\RelationshipLink; -use EDT\Querying\Utilities\ConditionEvaluator; -use EDT\Querying\Utilities\Reindexer; -use EDT\Querying\Utilities\Sorter; -use EDT\Querying\Utilities\TableJoiner; use EDT\Wrapping\Contracts\TypeProviderInterface; use EDT\Wrapping\Contracts\Types\FilteringTypeInterface; use EDT\Wrapping\Contracts\Types\SortingTypeInterface; @@ -26,6 +25,7 @@ use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\PathToManyRelationshipSetBehavior; use EDT\Wrapping\ResourceBehavior\ResourceReadability; use EDT\Wrapping\ResourceBehavior\ResourceUpdatability; +use Symfony\Component\Validator\Validation; use Tests\data\AdModel\Person; use Webmozart\Assert\Assert; @@ -34,12 +34,16 @@ class AuthorType implements FilteringTypeInterface, SortingTypeInterface { + protected readonly RepositoryInterface $repository; + public function __construct( - protected readonly PathsBasedConditionFactoryInterface $conditionFactory, + protected readonly ConditionFactoryInterface $conditionFactory, protected readonly TypeProviderInterface $typeProvider, protected readonly PropertyAccessorInterface $propertyAccessor, protected readonly AttributeTypeResolver $typeResolver - ) {} + ) { + $this->repository = PhpEntityRepository::createDefault(Validation::createValidator(), new ReflectionPropertyAccessor(), []); + } public function getReadability(): ResourceReadability { @@ -64,7 +68,6 @@ public function getReadability(): ResourceReadability $this->getEntityClass(), ['id'], $this->propertyAccessor, - $this->typeResolver ) ); } @@ -162,25 +165,20 @@ public function updateEntity(string $entityId, EntityDataInterface $entityData): public function assertMatchingEntity(object $entity, array $conditions): void { - $tableJoiner = new TableJoiner($this->propertyAccessor); - $conditionEvaluator = new ConditionEvaluator($tableJoiner); $conditions = array_merge($conditions, $this->getAccessConditions()); - Assert::true($conditionEvaluator->evaluateConditions($entity, $conditions)); + Assert::true($this->repository->isMatchingEntity($entity, $conditions)); } public function isMatchingEntity(object $entity, array $conditions): bool { $conditions = array_merge($conditions, $this->getAccessConditions()); - $tableJoiner = new TableJoiner($this->propertyAccessor); - return (new ConditionEvaluator($tableJoiner))->evaluateConditions($entity, $conditions); + return $this->repository->isMatchingEntity($entity, $conditions); } public function reindexEntities(array $entities, array $conditions, array $sortMethods): array { - $tableJoiner = new TableJoiner($this->propertyAccessor); - $reindexer = new Reindexer(new ConditionEvaluator($tableJoiner), new Sorter($tableJoiner)); - return $reindexer->reindexEntities($entities, $conditions, $sortMethods); + return $this->repository->reindexEntities($entities, $conditions, $sortMethods); } public function getEntityForRelationship(string $identifier, array $conditions): object diff --git a/packages/access-definitions/tests/data/Types/BirthType.php b/packages/access-definitions/tests/data/Types/BirthType.php index 43e0280f..16f01ad4 100644 --- a/packages/access-definitions/tests/data/Types/BirthType.php +++ b/packages/access-definitions/tests/data/Types/BirthType.php @@ -4,15 +4,14 @@ namespace Tests\data\Types; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; +use EDT\ConditionFactory\ConditionFactoryInterface; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use Tests\data\AdModel\Birth; class BirthType implements EntityBasedInterface { public function __construct( - protected readonly PathsBasedConditionFactoryInterface $conditionFactory + protected readonly ConditionFactoryInterface $conditionFactory ) {} diff --git a/packages/access-definitions/tests/data/Types/BookType.php b/packages/access-definitions/tests/data/Types/BookType.php index 7e1ae74f..200e6253 100644 --- a/packages/access-definitions/tests/data/Types/BookType.php +++ b/packages/access-definitions/tests/data/Types/BookType.php @@ -4,7 +4,7 @@ namespace Tests\data\Types; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; +use EDT\ConditionFactory\ConditionFactoryInterface; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\JsonApi\RequestHandling\ExpectedPropertyCollection; use EDT\JsonApi\RequestHandling\ModifiedEntity; @@ -43,7 +43,7 @@ public function setAvailableInstances(array $instances): void } public function __construct( - protected readonly PathsBasedConditionFactoryInterface $conditionFactory, + protected readonly ConditionFactoryInterface $conditionFactory, protected readonly TypeProviderInterface $typeProvider, protected readonly PropertyAccessorInterface $propertyAccessor, protected readonly AttributeTypeResolver $typeResolver, diff --git a/packages/dql/src/ClassGeneration/ResourceConfigBuilderFromEntityGenerator.php b/packages/dql/src/ClassGeneration/ResourceConfigBuilderFromEntityGenerator.php index 4171f579..1bbe1c52 100644 --- a/packages/dql/src/ClassGeneration/ResourceConfigBuilderFromEntityGenerator.php +++ b/packages/dql/src/ClassGeneration/ResourceConfigBuilderFromEntityGenerator.php @@ -34,8 +34,6 @@ class ResourceConfigBuilderFromEntityGenerator * @param null|callable(TypeInterface): TypeInterface $relationshipTypeCallback adjust the relationship type to be used in the property type hint */ public function __construct( - protected readonly TypeInterface $conditionType, - protected readonly TypeInterface $sortingType, protected readonly ClassOrInterfaceType $parentClass, protected readonly DocblockPropertyByTraitEvaluator $traitEvaluator, protected readonly mixed $entityTypeCallback = null, @@ -118,7 +116,7 @@ protected function mapToClass(ClassOrInterfaceType $entityClass, Column|OneToMan if ($annotationOrAttribute instanceof Column) { $class = AttributeConfigBuilderInterface::class; - return ClassOrInterfaceType::fromFqcn($class, [$this->conditionType, $entityClass]); + return ClassOrInterfaceType::fromFqcn($class, [$entityClass]); } $class = $annotationOrAttribute instanceof ManyToMany || $annotationOrAttribute instanceof OneToMany @@ -134,8 +132,6 @@ protected function mapToClass(ClassOrInterfaceType $entityClass, Column|OneToMan } $templateParameters = [ - $this->conditionType, - $this->sortingType, $entityClass, // TODO: parse docblock further to detect types with template parameters $targetEntityClass diff --git a/packages/dql/src/ConditionFactories/DqlConditionFactory.php b/packages/dql/src/ConditionFactories/DqlConditionFactory.php index 5478c35c..3b8cce8a 100644 --- a/packages/dql/src/ConditionFactories/DqlConditionFactory.php +++ b/packages/dql/src/ConditionFactories/DqlConditionFactory.php @@ -4,7 +4,8 @@ namespace EDT\DqlQuerying\ConditionFactories; -use EDT\ConditionFactory\PathsBasedConditionGroupFactoryInterface; +use EDT\ConditionFactory\ConditionFactoryInterface; +use EDT\ConditionFactory\ConditionGroupFactoryInterface; use EDT\DqlQuerying\Contracts\ClauseFunctionInterface; use EDT\DqlQuerying\Functions\AllTrue; use EDT\DqlQuerying\Functions\AnyTrue; @@ -28,7 +29,6 @@ use EDT\DqlQuerying\Functions\Size; use EDT\DqlQuerying\Functions\TargetEntity; use EDT\DqlQuerying\Functions\Value; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; use EDT\Querying\Contracts\PathException; use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyPathAccessInterface; @@ -37,10 +37,10 @@ use function count; /** - * @template-implements PathsBasedConditionFactoryInterface> - * @template-implements PathsBasedConditionGroupFactoryInterface> + * @template-implements ConditionFactoryInterface> + * @template-implements ConditionGroupFactoryInterface> */ -class DqlConditionFactory implements PathsBasedConditionFactoryInterface, PathsBasedConditionGroupFactoryInterface +class DqlConditionFactory implements ConditionFactoryInterface, ConditionGroupFactoryInterface { /** * @return ClauseFunctionInterface @@ -263,7 +263,7 @@ public function propertyEndsWithCaseInsensitive(string $value, string|array|Prop * * Because a condition needs all information in a single row, we need to create a separate * join for each required value. To clarify this, consider the following tables, continuing - * the example in {@link PathsBasedConditionFactoryInterface::allValuesPresentInMemberListProperties()}: + * the example in {@link ConditionFactoryInterface::allValuesPresentInMemberListProperties()}: * * ``` * author diff --git a/packages/dql/src/ObjectProviders/DoctrineOrmEntityProvider.php b/packages/dql/src/ObjectProviders/DoctrineOrmEntityProvider.php index b10239ba..e9197678 100644 --- a/packages/dql/src/ObjectProviders/DoctrineOrmEntityProvider.php +++ b/packages/dql/src/ObjectProviders/DoctrineOrmEntityProvider.php @@ -19,11 +19,9 @@ use function is_a; /** - * @template TCondition of ClauseInterface - * @template TSorting of OrderByInterface * @template TEntity of object * - * @template-implements OffsetEntityProviderInterface + * @template-implements OffsetEntityProviderInterface */ class DoctrineOrmEntityProvider implements OffsetEntityProviderInterface { diff --git a/packages/dql/src/SortMethodFactories/SortMethodFactory.php b/packages/dql/src/SortMethodFactories/SortMethodFactory.php index 9d1a2ec4..e456670a 100644 --- a/packages/dql/src/SortMethodFactories/SortMethodFactory.php +++ b/packages/dql/src/SortMethodFactories/SortMethodFactory.php @@ -8,7 +8,6 @@ use EDT\DqlQuerying\SortMethods\Ascending; use EDT\DqlQuerying\SortMethods\Descending; use EDT\DqlQuerying\Contracts\OrderBySortMethodInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyPathAccessInterface; use EDT\Querying\Contracts\PropertyPathInterface; use EDT\Querying\Contracts\SortMethodFactoryInterface; @@ -19,13 +18,13 @@ */ class SortMethodFactory implements SortMethodFactoryInterface { - public function propertyAscending(string|array|PropertyPathInterface $properties): PathsBasedInterface + public function propertyAscending(string|array|PropertyPathInterface $properties) { $propertyPath = new PropertyPath(null, '', PropertyPathAccessInterface::UNPACK_RECURSIVE, $properties); return new Ascending(new Property($propertyPath)); } - public function propertyDescending(string|array|PropertyPathInterface $properties): PathsBasedInterface + public function propertyDescending(string|array|PropertyPathInterface $properties) { $propertyPath = new PropertyPath(null, '', PropertyPathAccessInterface::UNPACK_RECURSIVE, $properties); return new Descending(new Property($propertyPath)); diff --git a/packages/dql/tests/ClassGeneration/ResourceConfigBuilderFromEntityGeneratorTest.php b/packages/dql/tests/ClassGeneration/ResourceConfigBuilderFromEntityGeneratorTest.php index a2145aa6..fec93fd9 100644 --- a/packages/dql/tests/ClassGeneration/ResourceConfigBuilderFromEntityGeneratorTest.php +++ b/packages/dql/tests/ClassGeneration/ResourceConfigBuilderFromEntityGeneratorTest.php @@ -25,12 +25,10 @@ class ResourceConfigBuilderFromEntityGeneratorTest extends TestCase namespace Foobar; -use EDT\DqlQuerying\Contracts\OrderBySortMethodInterface; use EDT\JsonApi\PropertyConfig\Builder\AttributeConfigBuilderInterface; use EDT\JsonApi\PropertyConfig\Builder\ToManyRelationshipConfigBuilderInterface; use EDT\JsonApi\PropertyConfig\Builder\ToOneRelationshipConfigBuilderInterface; use EDT\JsonApi\ResourceConfig\Builder\MagicResourceConfigBuilder; -use EDT\Querying\Contracts\FunctionInterface; use Tests\ClassGeneration\EntityA; use Tests\ClassGeneration\EntityB; @@ -41,18 +39,18 @@ class ResourceConfigBuilderFromEntityGeneratorTest extends TestCase * To add additional properties, you may want to * create an extending class and add them there. * - * @template-extends MagicResourceConfigBuilder,OrderBySortMethodInterface,EntityA> + * @template-extends MagicResourceConfigBuilder * - * @property-read AttributeConfigBuilderInterface,EntityA> $propertyA {@link EntityA::propertyA} - * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityA,EntityB> $propertyB {@link EntityA::propertyB} - * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityA,EntityB> $propertyC {@link EntityA::propertyC} - * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityA,EntityB> $propertyD {@link EntityA::propertyD} - * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityA,EntityB> $propertyE {@link EntityA::propertyE} - * @property-read AttributeConfigBuilderInterface,EntityA> $propertyF {@link EntityA::propertyF} - * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityA,EntityB> $propertyG {@link EntityA::propertyG} - * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityA,EntityB> $propertyH {@link EntityA::propertyH} - * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityA,EntityB> $propertyI {@link EntityA::propertyI} - * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityA,EntityB> $propertyJ {@link EntityA::propertyJ} + * @property-read AttributeConfigBuilderInterface $propertyA {@link EntityA::propertyA} + * @property-read ToManyRelationshipConfigBuilderInterface $propertyB {@link EntityA::propertyB} + * @property-read ToManyRelationshipConfigBuilderInterface $propertyC {@link EntityA::propertyC} + * @property-read ToOneRelationshipConfigBuilderInterface $propertyD {@link EntityA::propertyD} + * @property-read ToOneRelationshipConfigBuilderInterface $propertyE {@link EntityA::propertyE} + * @property-read AttributeConfigBuilderInterface $propertyF {@link EntityA::propertyF} + * @property-read ToManyRelationshipConfigBuilderInterface $propertyG {@link EntityA::propertyG} + * @property-read ToManyRelationshipConfigBuilderInterface $propertyH {@link EntityA::propertyH} + * @property-read ToOneRelationshipConfigBuilderInterface $propertyI {@link EntityA::propertyI} + * @property-read ToOneRelationshipConfigBuilderInterface $propertyJ {@link EntityA::propertyJ} */ class EntityAConfig extends MagicResourceConfigBuilder { @@ -64,12 +62,10 @@ class EntityAConfig extends MagicResourceConfigBuilder namespace Foobar; -use EDT\DqlQuerying\Contracts\OrderBySortMethodInterface; use EDT\JsonApi\PropertyConfig\Builder\AttributeConfigBuilderInterface; use EDT\JsonApi\PropertyConfig\Builder\ToManyRelationshipConfigBuilderInterface; use EDT\JsonApi\PropertyConfig\Builder\ToOneRelationshipConfigBuilderInterface; use EDT\JsonApi\ResourceConfig\Builder\MagicResourceConfigBuilder; -use EDT\Querying\Contracts\FunctionInterface; use Tests\ClassGeneration\EntityAInterface; use Tests\ClassGeneration\EntityBInterface; @@ -80,18 +76,18 @@ class EntityAConfig extends MagicResourceConfigBuilder * To add additional properties, you may want to * create an extending class and add them there. * - * @template-extends MagicResourceConfigBuilder,OrderBySortMethodInterface,EntityAInterface> + * @template-extends MagicResourceConfigBuilder * - * @property-read AttributeConfigBuilderInterface,EntityAInterface> $propertyA - * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyB - * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyC - * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyD - * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyE - * @property-read AttributeConfigBuilderInterface,EntityAInterface> $propertyF - * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyG - * @property-read ToManyRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyH - * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyI - * @property-read ToOneRelationshipConfigBuilderInterface,OrderBySortMethodInterface,EntityAInterface,EntityBInterface> $propertyJ + * @property-read AttributeConfigBuilderInterface $propertyA + * @property-read ToManyRelationshipConfigBuilderInterface $propertyB + * @property-read ToManyRelationshipConfigBuilderInterface $propertyC + * @property-read ToOneRelationshipConfigBuilderInterface $propertyD + * @property-read ToOneRelationshipConfigBuilderInterface $propertyE + * @property-read AttributeConfigBuilderInterface $propertyF + * @property-read ToManyRelationshipConfigBuilderInterface $propertyG + * @property-read ToManyRelationshipConfigBuilderInterface $propertyH + * @property-read ToOneRelationshipConfigBuilderInterface $propertyI + * @property-read ToOneRelationshipConfigBuilderInterface $propertyJ */ class EntityAConfig extends MagicResourceConfigBuilder { @@ -100,16 +96,8 @@ class EntityAConfig extends MagicResourceConfigBuilder public function testGenerateConfigBuilderClass(): void { - $conditionClass = ClassOrInterfaceType::fromFqcn( - FunctionInterface::class, - [NonClassOrInterfaceType::fromRawString('bool')] - ); - $sortingClass = ClassOrInterfaceType::fromFqcn(OrderBySortMethodInterface::class); $entityClass = ClassOrInterfaceType::fromFqcn(EntityA::class); - $parentClass = ClassOrInterfaceType::fromFqcn( - MagicResourceConfigBuilder::class, - [$conditionClass, $sortingClass, $entityClass] - ); + $parentClass = ClassOrInterfaceType::fromFqcn(MagicResourceConfigBuilder::class, [$entityClass]); $traitEvaluator = new DocblockPropertyByTraitEvaluator( new TraitEvaluator(), @@ -117,12 +105,7 @@ public function testGenerateConfigBuilderClass(): void [PropertyTag::PROPERTY_READ] ); - $generator = new ResourceConfigBuilderFromEntityGenerator( - $conditionClass, - $sortingClass, - $parentClass, - $traitEvaluator - ); + $generator = new ResourceConfigBuilderFromEntityGenerator($parentClass, $traitEvaluator); $file = $generator->generateConfigBuilderClass( $entityClass, @@ -136,17 +119,9 @@ public function testGenerateConfigBuilderClass(): void public function testGenerateConfigBuilderClassWithInterfaces(): void { - $conditionClass = ClassOrInterfaceType::fromFqcn( - FunctionInterface::class, - [NonClassOrInterfaceType::fromRawString('bool')] - ); - $sortingClass = ClassOrInterfaceType::fromFqcn(OrderBySortMethodInterface::class); $entityClass = ClassOrInterfaceType::fromFqcn(EntityA::class); $interfaceClass = ClassOrInterfaceType::fromFqcn(EntityAInterface::class); - $parentClass = ClassOrInterfaceType::fromFqcn( - MagicResourceConfigBuilder::class, - [$conditionClass, $sortingClass, $interfaceClass] - ); + $parentClass = ClassOrInterfaceType::fromFqcn(MagicResourceConfigBuilder::class, [$interfaceClass]); $traitEvaluator = new DocblockPropertyByTraitEvaluator( new TraitEvaluator(), @@ -162,8 +137,6 @@ protected function isCorrectInterface(string $interface, ReflectionClass $class) }; $generator = new ResourceConfigBuilderFromEntityGenerator( - $conditionClass, - $sortingClass, $parentClass, $traitEvaluator, $parentDetector, diff --git a/packages/dql/tests/DqlQuerying/ObjectProviders/DoctrineOrmEntityProviderTest.php b/packages/dql/tests/DqlQuerying/ObjectProviders/DoctrineOrmEntityProviderTest.php index 5c8c0e37..de06ad64 100644 --- a/packages/dql/tests/DqlQuerying/ObjectProviders/DoctrineOrmEntityProviderTest.php +++ b/packages/dql/tests/DqlQuerying/ObjectProviders/DoctrineOrmEntityProviderTest.php @@ -25,11 +25,19 @@ use EDT\DqlQuerying\Utilities\JoinFinder; use EDT\DqlQuerying\Utilities\QueryBuilderPreparer; use EDT\DqlQuerying\SortMethodFactories\SortMethodFactory; +use EDT\JsonApi\RequestHandling\JsonApiSortingParser; +use EDT\JsonApi\Validation\SortValidator; +use EDT\Querying\ConditionParsers\Drupal\DrupalConditionParser; +use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; +use EDT\Querying\ConditionParsers\Drupal\DrupalFilterValidator; +use EDT\Querying\ConditionParsers\Drupal\PredefinedDrupalConditionFactory; use EDT\Querying\Contracts\PropertyPathAccessInterface; use EDT\Querying\PropertyPaths\PropertyPath; use PHPUnit\Framework\TestCase; +use Symfony\Component\Validator\Validation; use Tests\data\DqlModel\Book; use Tests\data\DqlModel\Person; +use Tests\Querying\ConditionParsers\DrupalConditionFactoryTest; class DoctrineOrmEntityProviderTest extends TestCase { @@ -50,6 +58,10 @@ class DoctrineOrmEntityProviderTest extends TestCase * @var DoctrineOrmEntityProvider, OrderByInterface, Book> */ private DoctrineOrmEntityProvider $bookEntityProvider; + private JsonApiSortingParser $sortingTransformer; + private SortValidator $sortingValidator; + private DrupalFilterValidator $filterValidator; + private DrupalFilterParser $filterTransformer; protected function setUp(): void { @@ -75,6 +87,16 @@ protected function setUp(): void $joinFinder = new JoinFinder($metadataFactory); $bookBuilderPreparer = new QueryBuilderPreparer(Book::class, $metadataFactory, $joinFinder); $this->personBuilderPreparer = new QueryBuilderPreparer(Person::class, $metadataFactory, $joinFinder); + $predefinedDrupalConditionFactory = new PredefinedDrupalConditionFactory($this->conditionFactory); + $validator = Validation::createValidator(); + $this->filterValidator = new DrupalFilterValidator($validator, $predefinedDrupalConditionFactory); + $this->filterTransformer = new DrupalFilterParser( + $this->conditionFactory, + new DrupalConditionParser($predefinedDrupalConditionFactory), + $this->filterValidator + ); + $this->sortingTransformer = new JsonApiSortingParser($this->sortingFactory); + $this->sortingValidator = new SortValidator($validator); $this->bookEntityProvider = new DoctrineOrmEntityProvider( $this->entityManager, $bookBuilderPreparer, diff --git a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalConditionFactoryInterface.php b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalConditionFactoryInterface.php index 6b460bc6..9a2a4887 100644 --- a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalConditionFactoryInterface.php +++ b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalConditionFactoryInterface.php @@ -4,11 +4,8 @@ namespace EDT\Querying\ConditionParsers\Drupal; -use EDT\Querying\Contracts\PathsBasedInterface; -use Symfony\Component\Validator\Constraint; - /** - * @template TCondition of PathsBasedInterface + * @template TCondition * @phpstan-import-type DrupalValue from DrupalFilterParser */ interface DrupalConditionFactoryInterface extends OperatorConstraintProviderInterface @@ -22,7 +19,7 @@ interface DrupalConditionFactoryInterface extends OperatorConstraintProviderInte * * @throws DrupalFilterException if the given operator name is not supported */ - public function createConditionWithValue(string $operatorName, array|string|int|float|bool|null $value, ?array $path): PathsBasedInterface; + public function createConditionWithValue(string $operatorName, array|string|int|float|bool|null $value, ?array $path); /** * @param non-empty-string $operatorName @@ -32,5 +29,5 @@ public function createConditionWithValue(string $operatorName, array|string|int| * * @throws DrupalFilterException if the given operator name is not supported */ - public function createConditionWithoutValue(string $operatorName, ?array $path): PathsBasedInterface; + public function createConditionWithoutValue(string $operatorName, ?array $path); } diff --git a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalConditionParser.php b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalConditionParser.php index 33f7682a..a559f0e7 100644 --- a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalConditionParser.php +++ b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalConditionParser.php @@ -6,7 +6,7 @@ use EDT\Querying\Conditions\Equals; use EDT\Querying\Contracts\ConditionParserInterface; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\Querying\Utilities\PathConverterTrait; use function array_key_exists; /** @@ -18,11 +18,13 @@ * * @phpstan-import-type DrupalFilterCondition from DrupalFilterParser * - * @template TCondition of PathsBasedInterface + * @template TCondition * @template-implements ConditionParserInterface */ class DrupalConditionParser implements ConditionParserInterface { + use PathConverterTrait; + /** * @param DrupalConditionFactoryInterface $drupalConditionFactory * @param non-empty-string $defaultOperator @@ -35,7 +37,7 @@ public function __construct( /** * @throws DrupalFilterException */ - public function parseCondition(array $condition): PathsBasedInterface + public function parseCondition(array $condition) { $operatorName = array_key_exists(DrupalFilterParser::OPERATOR, $condition) ? $condition[DrupalFilterParser::OPERATOR] @@ -49,13 +51,7 @@ public function parseCondition(array $condition): PathsBasedInterface $pathString = $condition[DrupalFilterParser::PATH] ?? null; $path = null === $pathString ? null - : array_map(static function (string $pathSegment) use ($operatorName, $pathString): string { - if ('' === $pathSegment) { - throw DrupalFilterException::emptyPathSegment($operatorName, $pathString); - } - - return $pathSegment; - }, explode('.', $pathString)); + : self::inputPathToArray($pathString); return array_key_exists(DrupalFilterParser::VALUE, $condition) ? $this->drupalConditionFactory->createConditionWithValue($operatorName, $condition[DrupalFilterParser::VALUE], $path) diff --git a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterException.php b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterException.php index d7d78e62..7e236737 100644 --- a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterException.php +++ b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterException.php @@ -43,13 +43,4 @@ public static function emergencyAbort(int $iterations): self { return new self("Can't build tree. Does it contain a loop (ie. a condition group referencing itself, directly or indirectly)? Aborted after $iterations iterations"); } - - /** - * @param non-empty-string $operatorName - * @param non-empty-string $pathString - */ - public static function emptyPathSegment(string $operatorName, string $pathString): self - { - return new self("Path '$pathString' used in operator '$operatorName' contains an empty path segment."); - } } diff --git a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterParser.php b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterParser.php index 8c9b851e..37d179f8 100644 --- a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterParser.php +++ b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterParser.php @@ -4,10 +4,9 @@ namespace EDT\Querying\ConditionParsers\Drupal; -use EDT\ConditionFactory\PathsBasedConditionGroupFactoryInterface; +use EDT\ConditionFactory\ConditionGroupFactoryInterface; use EDT\JsonApi\RequestHandling\FilterParserInterface; use EDT\Querying\Contracts\ConditionParserInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use function count; use function in_array; @@ -27,7 +26,7 @@ * operator?: non-empty-string, * memberOf?: non-empty-string * } - * @template TCondition of PathsBasedInterface + * @template TCondition * @template-implements FilterParserInterface, TCondition> */ class DrupalFilterParser implements FilterParserInterface @@ -91,12 +90,12 @@ class DrupalFilterParser implements FilterParserInterface public const VALUE = 'value'; /** - * @param PathsBasedConditionGroupFactoryInterface $conditionGroupFactory + * @param ConditionGroupFactoryInterface $conditionGroupFactory * @param ConditionParserInterface $conditionParser * @param positive-int $maxIterations How deep groups are allowed to be nested. */ public function __construct( - protected readonly PathsBasedConditionGroupFactoryInterface $conditionGroupFactory, + protected readonly ConditionGroupFactoryInterface $conditionGroupFactory, protected readonly ConditionParserInterface $conditionParser, protected readonly DrupalFilterValidator $filterValidator, int $maxIterations = 5000 @@ -193,7 +192,7 @@ public function validateFilter(mixed $filter): array * * @throws DrupalFilterException */ - protected function createGroup(string $conjunction, array $conditions): PathsBasedInterface + protected function createGroup(string $conjunction, array $conditions) { return match ($conjunction) { self::AND => $this->conditionGroupFactory->allConditionsApply(...$conditions), diff --git a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterValidator.php b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterValidator.php index fba38854..20919bda 100644 --- a/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterValidator.php +++ b/packages/extra/src/Querying/ConditionParsers/Drupal/DrupalFilterValidator.php @@ -31,12 +31,12 @@ class DrupalFilterValidator public function __construct( protected ValidatorInterface $validator, - OperatorConstraintProviderInterface $drupalConditionFactory + OperatorConstraintProviderInterface $operatorConstraintProvider ) { $this->collectionConstraintFactory = new CollectionConstraintFactory(); $this->filterNamesConstraints = $this->getFilterNamesConstraints(); - $supportedOperators = $drupalConditionFactory->getSupportedOperators(); + $supportedOperators = $operatorConstraintProvider->getSupportedOperators(); $this->filterSchemaConstraints = $this->getFilterSchemaConstraints($supportedOperators); } diff --git a/packages/extra/src/Querying/ConditionParsers/Drupal/PredefinedDrupalConditionFactory.php b/packages/extra/src/Querying/ConditionParsers/Drupal/PredefinedDrupalConditionFactory.php index 79bfc5c4..cd125231 100644 --- a/packages/extra/src/Querying/ConditionParsers/Drupal/PredefinedDrupalConditionFactory.php +++ b/packages/extra/src/Querying/ConditionParsers/Drupal/PredefinedDrupalConditionFactory.php @@ -4,7 +4,7 @@ namespace EDT\Querying\ConditionParsers\Drupal; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; +use EDT\ConditionFactory\ConditionFactoryInterface; use EDT\Querying\Conditions\ArrayContains; use EDT\Querying\Conditions\Between; use EDT\Querying\Conditions\EndsWith; @@ -19,9 +19,10 @@ use EDT\Querying\Conditions\NotBetween; use EDT\Querying\Conditions\NotEquals; use EDT\Querying\Conditions\NotIn; +use EDT\Querying\Conditions\NotSize; +use EDT\Querying\Conditions\Size; use EDT\Querying\Conditions\StartsWith; use EDT\Querying\Conditions\StringContains; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Drupal\ConditionValueException; use Webmozart\Assert\Assert; use function array_key_exists; @@ -29,10 +30,10 @@ use function is_string; /** - * @template TCondition of PathsBasedInterface + * @template TCondition * @template-implements DrupalConditionFactoryInterface * - * @phpstan-import-type DrupalValue from DrupalConditionFactoryInterface + * @phpstan-import-type DrupalValue from DrupalFilterParser */ class PredefinedDrupalConditionFactory implements DrupalConditionFactoryInterface { @@ -47,10 +48,10 @@ class PredefinedDrupalConditionFactory implements DrupalConditionFactoryInterfac private array $operatorFunctionsWithoutValue; /** - * @param PathsBasedConditionFactoryInterface $conditionFactory + * @param ConditionFactoryInterface $conditionFactory */ public function __construct( - protected readonly PathsBasedConditionFactoryInterface $conditionFactory + protected readonly ConditionFactoryInterface $conditionFactory ) { $this->operatorFunctionsWithValue = $this->getOperatorFunctionsWithValue(); $this->operatorFunctionsWithoutValue = $this->getOperatorFunctionsWithoutValue(); @@ -67,7 +68,7 @@ public function getSupportedOperators(): array ); } - public function createConditionWithValue(string $operatorName, array|string|int|float|bool|null $value, ?array $path): PathsBasedInterface + public function createConditionWithValue(string $operatorName, array|string|int|float|bool|null $value, ?array $path) { if (!array_key_exists($operatorName, $this->operatorFunctionsWithValue)) { throw DrupalFilterException::unknownCondition($operatorName, ...array_keys($this->getSupportedOperators())); @@ -76,7 +77,7 @@ public function createConditionWithValue(string $operatorName, array|string|int| return $this->operatorFunctionsWithValue[$operatorName]($value, $path); } - public function createConditionWithoutValue(string $operatorName, ?array $path): PathsBasedInterface + public function createConditionWithoutValue(string $operatorName, ?array $path) { if (!array_key_exists($operatorName, $this->operatorFunctionsWithoutValue)) { throw DrupalFilterException::unknownCondition($operatorName, ...array_keys($this->getSupportedOperators())); @@ -107,6 +108,17 @@ protected function assertString(mixed $value): string return $value; } + /** + * @return int<0,max> + */ + protected function assertNonNegativeInt(mixed $value): int + { + Assert::integer($value); + Assert::greaterThanEq($value, 0); + + return $value; + } + /** * @return list */ @@ -164,11 +176,11 @@ protected function getOperatorFunctionsWithValue(): array StringContains::OPERATOR => fn ($value, ?array $path) => $this->conditionFactory->propertyHasStringContainingCaseInsensitiveValue($this->assertString($value), $this->assertPath($path)), In::OPERATOR => fn ($value, ?array $path) => $this->conditionFactory->propertyHasAnyOfValues($this->assertNonEmptyList($value), $this->assertPath($path)), NotIn::OPERATOR => fn ($value, ?array $path) => $this->conditionFactory->propertyHasNotAnyOfValues($this->assertNonEmptyList($value), $this->assertPath($path)), - Between::OPERATOR => function ($value, ?array $path): PathsBasedInterface { + Between::OPERATOR => function ($value, ?array $path) { $value = $this->assertRange($value); return $this->conditionFactory->propertyBetweenValuesInclusive($value[0], $value[1], $this->assertPath($path)); }, - NotBetween::OPERATOR => function ($value, ?array $path): PathsBasedInterface { + NotBetween::OPERATOR => function ($value, ?array $path) { $value = $this->assertRange($value); return $this->conditionFactory->propertyNotBetweenValuesInclusive($value[0], $value[1], $this->assertPath($path)); }, @@ -179,6 +191,8 @@ protected function getOperatorFunctionsWithValue(): array LesserEqualsThan::OPERATOR => fn ($value, ?array $path) => $this->conditionFactory->valueSmallerEqualsThan($this->assertNumeric($value), $this->assertPath($path)), StartsWith::OPERATOR => fn ($value, ?array $path) => $this->conditionFactory->propertyStartsWithCaseInsensitive($this->assertString($value), $this->assertPath($path)), EndsWith::OPERATOR => fn ($value, ?array $path) => $this->conditionFactory->propertyEndsWithCaseInsensitive($this->assertString($value), $this->assertPath($path)), + NotSize::OPERATOR => fn ($value, ?array $path) => $this->conditionFactory->propertyHasNotSize($this->assertNonNegativeInt($value), $this->assertPath($path)), + Size::OPERATOR => fn ($value, ?array $path) => $this->conditionFactory->propertyHasSize($this->assertNonNegativeInt($value), $this->assertPath($path)), ]; } @@ -188,8 +202,8 @@ protected function getOperatorFunctionsWithValue(): array protected function getOperatorFunctionsWithoutValue(): array { return [ - IsNull::OPERATOR => fn (?array $path): PathsBasedInterface => $this->conditionFactory->propertyIsNull($this->assertPath($path)), - IsNotNull::OPERATOR => fn (?array $path): PathsBasedInterface => $this->conditionFactory->propertyIsNotNull($this->assertPath($path)), + IsNull::OPERATOR => fn (?array $path) => $this->conditionFactory->propertyIsNull($this->assertPath($path)), + IsNotNull::OPERATOR => fn (?array $path) => $this->conditionFactory->propertyIsNotNull($this->assertPath($path)), ]; } diff --git a/packages/extra/src/Querying/ConditionParsers/Drupal/PrefilledDrupalCondtionTransformer.php b/packages/extra/src/Querying/ConditionParsers/Drupal/PrefilledDrupalCondtionTransformer.php index 4aa0c18e..b36e97cc 100644 --- a/packages/extra/src/Querying/ConditionParsers/Drupal/PrefilledDrupalCondtionTransformer.php +++ b/packages/extra/src/Querying/ConditionParsers/Drupal/PrefilledDrupalCondtionTransformer.php @@ -4,7 +4,6 @@ namespace EDT\Querying\ConditionParsers\Drupal; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Conditions\ConditionInterface; use EDT\Querying\Conditions\ValueDependentConditionInterface; use EDT\Querying\Conditions\ValueIndependentConditionInterface; @@ -12,7 +11,7 @@ use Webmozart\Assert\Assert; /** - * @template TCondition of PathsBasedInterface + * @template TCondition * * @template-implements DrupalConditionFactoryInterface */ @@ -45,7 +44,7 @@ public function getSupportedOperators(): array ); } - public function createConditionWithValue(string $operatorName, float|int|bool|array|string|null $value, ?array $path): PathsBasedInterface + public function createConditionWithValue(string $operatorName, float|int|bool|array|string|null $value, ?array $path) { $operator = $this->getOperator($operatorName); Assert::isInstanceOf($operator, ValueDependentConditionInterface::class); @@ -53,7 +52,7 @@ public function createConditionWithValue(string $operatorName, float|int|bool|ar return $operator->transform($path, $value); } - public function createConditionWithoutValue(string $operatorName, ?array $path): PathsBasedInterface + public function createConditionWithoutValue(string $operatorName, ?array $path) { $operator = $this->getOperator($operatorName); Assert::isInstanceOf($operator, ValueIndependentConditionInterface::class); diff --git a/packages/extra/tests/Querying/ConditionParsers/DrupalConditionFactoryTest.php b/packages/extra/tests/Querying/ConditionParsers/DrupalConditionFactoryTest.php index 052ee990..65126e4f 100644 --- a/packages/extra/tests/Querying/ConditionParsers/DrupalConditionFactoryTest.php +++ b/packages/extra/tests/Querying/ConditionParsers/DrupalConditionFactoryTest.php @@ -4,13 +4,13 @@ namespace Tests\Querying\ConditionParsers; +use EDT\ConditionFactory\ConditionFactoryInterface; use EDT\Querying\ConditionFactories\PhpConditionFactory; use EDT\Querying\ConditionParsers\Drupal\DrupalConditionParser; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterException; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterValidator; use EDT\Querying\ConditionParsers\Drupal\PredefinedDrupalConditionFactory; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; use EDT\Querying\Functions\InvertedBoolean; use EDT\Querying\Functions\IsNull; use PHPUnit\Framework\TestCase; @@ -18,7 +18,7 @@ class DrupalConditionFactoryTest extends TestCase { - private PathsBasedConditionFactoryInterface $conditionFactory; + private ConditionFactoryInterface $conditionFactory; private DrupalFilterParser $filterFactory; diff --git a/packages/jsonapi/bin/generate_config b/packages/jsonapi/bin/generate_config index f5e73dce..62993e9b 100644 --- a/packages/jsonapi/bin/generate_config +++ b/packages/jsonapi/bin/generate_config @@ -50,12 +50,7 @@ $parentClass = ClassOrInterfaceType::fromFqcn( TypeConfig::class, [$conditionClass, $sortingClass, $entityClass] ); -$configGenerator = new ResourceConfigBuilderFromEntityGenerator( - $conditionClass, - $sortingClass, - $parentClass, - $traitEvaluator -); +$configGenerator = new ResourceConfigBuilderFromEntityGenerator($parentClass, $traitEvaluator); $entityShortName = $entityClass->getShortClassName(); $configBuilderClassName = "{$entityShortName}BasedResourceConfigBuilderTemplate"; diff --git a/packages/jsonapi/src/ApiDocumentation/ActionConfigInterface.php b/packages/jsonapi/src/ApiDocumentation/ActionConfigInterface.php index 8f72ffb4..a8e3ac38 100644 --- a/packages/jsonapi/src/ApiDocumentation/ActionConfigInterface.php +++ b/packages/jsonapi/src/ApiDocumentation/ActionConfigInterface.php @@ -4,9 +4,6 @@ namespace EDT\JsonApi\ApiDocumentation; -use EDT\Querying\Contracts\PathsBasedInterface; -use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; - interface ActionConfigInterface { /** diff --git a/packages/jsonapi/src/ApiDocumentation/OpenApiDocumentBuilder.php b/packages/jsonapi/src/ApiDocumentation/OpenApiDocumentBuilder.php index c2bb53ea..a770e105 100644 --- a/packages/jsonapi/src/ApiDocumentation/OpenApiDocumentBuilder.php +++ b/packages/jsonapi/src/ApiDocumentation/OpenApiDocumentBuilder.php @@ -13,8 +13,6 @@ use cebe\openapi\spec\Response; use cebe\openapi\spec\Schema; use cebe\openapi\spec\Tag; -use EDT\Querying\Contracts\PathsBasedInterface; -use EDT\Wrapping\Contracts\Types\NamedTypeInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; use function count; @@ -39,8 +37,8 @@ class OpenApiDocumentBuilder /** * @param int<0, max> $defaultPageSize - * @param array> $getableTypes - * @param array> $listableTypes + * @param array> $getableTypes + * @param array> $listableTypes */ public function __construct( protected readonly SchemaStore $schemaStore, @@ -104,7 +102,7 @@ protected function addPath(OpenApi $openApi, string $baseUrl, PathItem $pathItem } /** - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * @param non-empty-string $typeName * * @throws TypeErrorException @@ -153,7 +151,7 @@ protected function addListOperation( } /** - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * @param non-empty-string $typeName * * @throws TypeErrorException diff --git a/packages/jsonapi/src/ApiDocumentation/OpenApiWordingInterface.php b/packages/jsonapi/src/ApiDocumentation/OpenApiWordingInterface.php index 980d1d76..f9e643d6 100644 --- a/packages/jsonapi/src/ApiDocumentation/OpenApiWordingInterface.php +++ b/packages/jsonapi/src/ApiDocumentation/OpenApiWordingInterface.php @@ -4,9 +4,6 @@ namespace EDT\JsonApi\ApiDocumentation; -use EDT\Querying\Contracts\PathsBasedInterface; -use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; - interface OpenApiWordingInterface { public function getOpenApiDescription(): string; diff --git a/packages/jsonapi/src/ApiDocumentation/SchemaStore.php b/packages/jsonapi/src/ApiDocumentation/SchemaStore.php index e29bb3d6..109eb2ce 100644 --- a/packages/jsonapi/src/ApiDocumentation/SchemaStore.php +++ b/packages/jsonapi/src/ApiDocumentation/SchemaStore.php @@ -6,7 +6,6 @@ use cebe\openapi\exceptions\TypeErrorException; use cebe\openapi\spec\Schema; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\RelationshipInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use Exception; @@ -27,7 +26,7 @@ class SchemaStore protected array $schemas = []; /** - * @var array> + * @var array> */ protected array $schemasToCreate = []; @@ -48,7 +47,7 @@ public function findOrCreate(string $schemaName, callable $schemaBuilder): Schem } /** - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * @param non-empty-string $typeName * * @return non-empty-string @@ -109,7 +108,7 @@ public function reset(): void } /** - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * @param non-empty-string $typeName * * @throws TypeErrorException diff --git a/packages/jsonapi/src/Event/AfterCreationEvent.php b/packages/jsonapi/src/Event/AfterCreationEvent.php index b912051c..ab13c935 100644 --- a/packages/jsonapi/src/Event/AfterCreationEvent.php +++ b/packages/jsonapi/src/Event/AfterCreationEvent.php @@ -6,11 +6,8 @@ use EDT\JsonApi\RequestHandling\Body\CreationRequestBody; use EDT\JsonApi\ResourceTypes\CreatableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class AfterCreationEvent @@ -18,7 +15,7 @@ class AfterCreationEvent use ModifyEventTrait; /** - * @param CreatableTypeInterface $type + * @param CreatableTypeInterface $type * @param TEntity $entity */ public function __construct( @@ -28,7 +25,7 @@ public function __construct( ) {} /** - * @return CreatableTypeInterface + * @return CreatableTypeInterface */ public function getType(): CreatableTypeInterface { diff --git a/packages/jsonapi/src/Event/AfterDeletionEvent.php b/packages/jsonapi/src/Event/AfterDeletionEvent.php index 9d985797..e5c6aa1c 100644 --- a/packages/jsonapi/src/Event/AfterDeletionEvent.php +++ b/packages/jsonapi/src/Event/AfterDeletionEvent.php @@ -5,11 +5,8 @@ namespace EDT\JsonApi\Event; use EDT\JsonApi\ResourceTypes\DeletableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class AfterDeletionEvent diff --git a/packages/jsonapi/src/Event/AfterGetEvent.php b/packages/jsonapi/src/Event/AfterGetEvent.php index 67660cf5..bd2207f5 100644 --- a/packages/jsonapi/src/Event/AfterGetEvent.php +++ b/packages/jsonapi/src/Event/AfterGetEvent.php @@ -5,17 +5,14 @@ namespace EDT\JsonApi\Event; use EDT\JsonApi\ResourceTypes\GetableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class AfterGetEvent { /** - * @param GetableTypeInterface $type + * @param GetableTypeInterface $type * @param TEntity $entity */ public function __construct( @@ -24,7 +21,7 @@ public function __construct( ) {} /** - * @return GetableTypeInterface + * @return GetableTypeInterface */ public function getType(): GetableTypeInterface { diff --git a/packages/jsonapi/src/Event/AfterListEvent.php b/packages/jsonapi/src/Event/AfterListEvent.php index 64b19b7f..485484e5 100644 --- a/packages/jsonapi/src/Event/AfterListEvent.php +++ b/packages/jsonapi/src/Event/AfterListEvent.php @@ -5,17 +5,14 @@ namespace EDT\JsonApi\Event; use EDT\JsonApi\ResourceTypes\ListableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class AfterListEvent { /** - * @param ListableTypeInterface $type + * @param ListableTypeInterface $type * @param list $entities */ public function __construct( @@ -24,7 +21,7 @@ public function __construct( ) {} /** - * @return ListableTypeInterface + * @return ListableTypeInterface */ public function getType(): ListableTypeInterface { diff --git a/packages/jsonapi/src/Event/AfterUpdateEvent.php b/packages/jsonapi/src/Event/AfterUpdateEvent.php index e777225a..0126eb69 100644 --- a/packages/jsonapi/src/Event/AfterUpdateEvent.php +++ b/packages/jsonapi/src/Event/AfterUpdateEvent.php @@ -6,11 +6,8 @@ use EDT\JsonApi\RequestHandling\Body\UpdateRequestBody; use EDT\JsonApi\ResourceTypes\UpdatableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class AfterUpdateEvent @@ -18,7 +15,7 @@ class AfterUpdateEvent use ModifyEventTrait; /** - * @param UpdatableTypeInterface $type + * @param UpdatableTypeInterface $type * @param TEntity $entity */ public function __construct( @@ -28,7 +25,7 @@ public function __construct( ) {} /** - * @return UpdatableTypeInterface + * @return UpdatableTypeInterface */ public function getType(): UpdatableTypeInterface { diff --git a/packages/jsonapi/src/Event/BeforeCreationEvent.php b/packages/jsonapi/src/Event/BeforeCreationEvent.php index 782cd9fd..3be1456a 100644 --- a/packages/jsonapi/src/Event/BeforeCreationEvent.php +++ b/packages/jsonapi/src/Event/BeforeCreationEvent.php @@ -6,11 +6,8 @@ use EDT\JsonApi\RequestHandling\Body\CreationRequestBody; use EDT\JsonApi\ResourceTypes\CreatableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class BeforeCreationEvent @@ -18,7 +15,7 @@ class BeforeCreationEvent use ModifyEventTrait; /** - * @param CreatableTypeInterface $type + * @param CreatableTypeInterface $type */ public function __construct( protected readonly CreatableTypeInterface $type, @@ -26,7 +23,7 @@ public function __construct( ) {} /** - * @return CreatableTypeInterface + * @return CreatableTypeInterface */ public function getType(): CreatableTypeInterface { diff --git a/packages/jsonapi/src/Event/BeforeGetEvent.php b/packages/jsonapi/src/Event/BeforeGetEvent.php index 485794c5..d34516c9 100644 --- a/packages/jsonapi/src/Event/BeforeGetEvent.php +++ b/packages/jsonapi/src/Event/BeforeGetEvent.php @@ -5,24 +5,21 @@ namespace EDT\JsonApi\Event; use EDT\JsonApi\ResourceTypes\GetableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class BeforeGetEvent { /** - * @param GetableTypeInterface $type + * @param GetableTypeInterface $type */ public function __construct( protected readonly GetableTypeInterface $type ) {} /** - * @return GetableTypeInterface + * @return GetableTypeInterface */ public function getType(): GetableTypeInterface { diff --git a/packages/jsonapi/src/Event/BeforeListEvent.php b/packages/jsonapi/src/Event/BeforeListEvent.php index d2c399f2..5b634653 100644 --- a/packages/jsonapi/src/Event/BeforeListEvent.php +++ b/packages/jsonapi/src/Event/BeforeListEvent.php @@ -5,24 +5,21 @@ namespace EDT\JsonApi\Event; use EDT\JsonApi\ResourceTypes\ListableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class BeforeListEvent { /** - * @param ListableTypeInterface $type + * @param ListableTypeInterface $type */ public function __construct( protected readonly ListableTypeInterface $type ) {} /** - * @return ListableTypeInterface + * @return ListableTypeInterface */ public function getType(): ListableTypeInterface { diff --git a/packages/jsonapi/src/Event/BeforeUpdateEvent.php b/packages/jsonapi/src/Event/BeforeUpdateEvent.php index b192dacc..60b30e5a 100644 --- a/packages/jsonapi/src/Event/BeforeUpdateEvent.php +++ b/packages/jsonapi/src/Event/BeforeUpdateEvent.php @@ -6,11 +6,8 @@ use EDT\JsonApi\RequestHandling\Body\UpdateRequestBody; use EDT\JsonApi\ResourceTypes\UpdatableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class BeforeUpdateEvent @@ -18,7 +15,7 @@ class BeforeUpdateEvent use ModifyEventTrait; /** - * @param UpdatableTypeInterface $type + * @param UpdatableTypeInterface $type */ public function __construct( protected readonly UpdatableTypeInterface $type, @@ -26,7 +23,7 @@ public function __construct( ) {} /** - * @return UpdatableTypeInterface + * @return UpdatableTypeInterface */ public function getType(): UpdatableTypeInterface { diff --git a/packages/jsonapi/src/InputHandling/ConditionConverter.php b/packages/jsonapi/src/InputHandling/ConditionConverter.php new file mode 100644 index 00000000..f3c4dfec --- /dev/null +++ b/packages/jsonapi/src/InputHandling/ConditionConverter.php @@ -0,0 +1,63 @@ + $filterTransformer + */ + public function __construct( + protected readonly DrupalFilterParser $filterTransformer, + protected readonly DrupalFilterValidator $filterValidator, + ) {} + + /** + * @template TCond + * + * @param ConditionFactoryInterface&ConditionGroupFactoryInterface $conditionFactory + * + * @return ConditionConverter + */ + public static function createDefault(ValidatorInterface $validator, ConditionFactoryInterface&ConditionGroupFactoryInterface $conditionFactory): self + { + $drupalConditionFactory = new PredefinedDrupalConditionFactory($conditionFactory); + $drupalConditionParser = new DrupalConditionParser($drupalConditionFactory); + $drupalFilterValidator = new DrupalFilterValidator($validator, $drupalConditionFactory); + $filterTransformer = new DrupalFilterParser($conditionFactory, $drupalConditionParser, $drupalFilterValidator); + + return new self($filterTransformer, $drupalFilterValidator); + } + + /** + * @param list $conditions + * + * @return list + */ + public function convertConditions(array $conditions): array + { + return array_merge(...array_map( + function (DrupalFilterInterface $filter): array { + $filterArray = $filter->toDrupalArray('root'); + $this->filterValidator->validateFilter($filterArray); + + return $this->filterTransformer->parseFilter($filterArray); + }, + $conditions + )); + } +} diff --git a/packages/jsonapi/src/InputHandling/FractalManagerFactory.php b/packages/jsonapi/src/InputHandling/FractalManagerFactory.php index fd49345d..3e7e1305 100644 --- a/packages/jsonapi/src/InputHandling/FractalManagerFactory.php +++ b/packages/jsonapi/src/InputHandling/FractalManagerFactory.php @@ -7,7 +7,6 @@ use EDT\JsonApi\OutputHandling\PropertyReadableTypeProviderInterface; use EDT\JsonApi\Validation\FieldsValidator; use EDT\JsonApi\Validation\IncludeValidator; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\TypeRetrievalAccessException; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use League\Fractal\Manager; @@ -27,7 +26,7 @@ public function __construct( } /** - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * @param string|null $rawIncludes * @param string|null $rawExcludes The JSON:API specification does not support excludes, but Fractal does. * diff --git a/packages/jsonapi/src/InputHandling/PhpEntityRepository.php b/packages/jsonapi/src/InputHandling/PhpEntityRepository.php new file mode 100644 index 00000000..746782f8 --- /dev/null +++ b/packages/jsonapi/src/InputHandling/PhpEntityRepository.php @@ -0,0 +1,149 @@ + + */ +class PhpEntityRepository implements RepositoryInterface +{ + /** + * @param ConditionConverter> $conditionConverter + * @param SortMethodConverter $sortMethodConverter + * @param ConditionFactoryInterface> $conditionFactory + * @param MutableEntityProvider $entityProvider + */ + public function __construct( + protected readonly ConditionConverter $conditionConverter, + protected readonly SortMethodConverter $sortMethodConverter, + protected readonly Reindexer $reindexer, + protected readonly ConditionFactoryInterface $conditionFactory, + protected readonly MutableEntityProvider $entityProvider + ) {} + + /** + * @template TEnt of object + * + * @param list $entities + * + * @return PhpEntityRepository + */ + public static function createDefault( + ValidatorInterface $validator, + PropertyAccessorInterface $propertyAccessor, + array $entities + ): self { + $conditionFactory = new PhpConditionFactory(); + $sortMethodFactory = new PhpSortMethodFactory(); + $conditionConverter = ConditionConverter::createDefault($validator, $conditionFactory); + $sortMethodConverter = SortMethodConverter::createDefault($validator, $sortMethodFactory); + $tableJoiner = new TableJoiner($propertyAccessor); + $conditionEvaluator = new ConditionEvaluator($tableJoiner); + $sorter = new Sorter($tableJoiner); + $reindexer = new Reindexer($conditionEvaluator, $sorter); + $entityProvider = new MutableEntityProvider($conditionEvaluator, $sorter, $entities); + + return new self( + $conditionConverter, + $sortMethodConverter, + $reindexer, + $conditionFactory, + $entityProvider + ); + } + + public function getEntityByIdentifier(string $id, array $conditions, array $identifierPropertyPath): object + { + $conditions = $this->conditionConverter->convertConditions($conditions); + $conditions[] = $this->conditionFactory->propertyHasValue($id, $identifierPropertyPath); + $entities = $this->entityProvider->getEntities($conditions, [], null); + + return match(count($entities)) { + 0 => throw new InvalidArgumentException('No entity found for the given ID and conditions.'), + 1 => array_pop($entities), + default => throw new InvalidArgumentException('Multiple entities found matching the given ID and conditions.') + }; + } + + public function getEntitiesByIdentifiers(array $identifiers, array $conditions, array $sortMethods, array $identifierPropertyPath): array + { + $conditions = $this->conditionConverter->convertConditions($conditions); + $sortMethods = $this->sortMethodConverter->convertSortMethods($sortMethods); + $conditions[] = $this->conditionFactory->propertyHasAnyOfValues($identifiers, $identifierPropertyPath); + + return $this->entityProvider->getEntities($conditions, $sortMethods, null); + } + + public function getEntities(array $conditions, array $sortMethods): array + { + $conditions = $this->conditionConverter->convertConditions($conditions); + $sortMethods = $this->sortMethodConverter->convertSortMethods($sortMethods); + + return $this->entityProvider->getEntities($conditions, $sortMethods, null); + } + + public function getEntitiesForPage(array $conditions, array $sortMethods, PagePagination $pagination): Pagerfanta + { + $conditions = $this->conditionConverter->convertConditions($conditions); + $sortMethods = $this->sortMethodConverter->convertSortMethods($sortMethods); + + $pageSize = $pagination->getSize(); + $pageNumber = $pagination->getNumber(); + $paginator = new OffsetPagination(($pageNumber - 1) * $pageSize, $pageSize); + $entities = $this->entityProvider->getEntities($conditions, $sortMethods, $paginator); + + return new Pagerfanta(new ArrayAdapter($entities)); + } + + public function deleteEntityByIdentifier(string $entityIdentifier, array $conditions, array $identifierPropertyPath): void + { + $conditions = $this->conditionConverter->convertConditions($conditions); + + $conditions[] = $this->conditionFactory->propertyHasValue($entityIdentifier, $identifierPropertyPath); + $this->entityProvider->removeEntities($conditions, 1); + } + + public function reindexEntities(array $entities, array $conditions, array $sortMethods): array + { + $conditions = $this->conditionConverter->convertConditions($conditions); + $sortMethods = $this->sortMethodConverter->convertSortMethods($sortMethods); + + return $this->reindexer->reindexEntities($entities, $conditions, $sortMethods); + } + + public function isMatchingEntity(object $entity, array $conditions): bool + { + $conditions = $this->conditionConverter->convertConditions($conditions); + + return $this->reindexer->isMatchingEntity($entity, $conditions); + } + + public function assertMatchingEntity(object $entity, array $conditions): void + { + $conditions = $this->conditionConverter->convertConditions($conditions); + + $this->reindexer->assertMatchingEntity($entity, $conditions); + } +} diff --git a/packages/jsonapi/src/InputHandling/ReadableRepositoryInterface.php b/packages/jsonapi/src/InputHandling/ReadableRepositoryInterface.php new file mode 100644 index 00000000..7b4bff97 --- /dev/null +++ b/packages/jsonapi/src/InputHandling/ReadableRepositoryInterface.php @@ -0,0 +1,32 @@ + $conditions + * @param list $sortMethods + * + * @return list + */ + public function getEntities(array $conditions, array $sortMethods): array; + + /** + * @param list $conditions + * @param list $sortMethods + * + * @return Pagerfanta + */ + public function getEntitiesForPage(array $conditions, array $sortMethods, PagePagination $pagination): Pagerfanta; +} diff --git a/packages/jsonapi/src/InputHandling/RepositoryInterface.php b/packages/jsonapi/src/InputHandling/RepositoryInterface.php index bd4e86fa..909da391 100644 --- a/packages/jsonapi/src/InputHandling/RepositoryInterface.php +++ b/packages/jsonapi/src/InputHandling/RepositoryInterface.php @@ -4,23 +4,22 @@ namespace EDT\JsonApi\InputHandling; -use EDT\Querying\Contracts\PathsBasedInterface; -use EDT\Querying\Pagination\PagePagination; +use EDT\ConditionFactory\DrupalFilterInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use Exception; -use Pagerfanta\Pagerfanta; /** * Allows to fetch and manipulate entities, as well as handle given ones regarding matching conditions and sort methods. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object + * + * @template-extends ReadableRepositoryInterface */ -interface RepositoryInterface +interface RepositoryInterface extends ReadableRepositoryInterface { /** * @param non-empty-string $id - * @param list $conditions + * @param list $conditions * @param non-empty-list $identifierPropertyPath * * @return TEntity @@ -28,9 +27,9 @@ interface RepositoryInterface public function getEntityByIdentifier(string $id, array $conditions, array $identifierPropertyPath): object; /** - * @param list $identifiers - * @param list $conditions - * @param list $sortMethods + * @param non-empty-list $identifiers + * @param list $conditions + * @param list $sortMethods * @param non-empty-list $identifierPropertyPath * * @return list @@ -42,27 +41,11 @@ public function getEntitiesByIdentifiers( array $identifierPropertyPath ): array; - /** - * @param list $conditions - * @param list $sortMethods - * - * @return list - */ - public function getEntities(array $conditions, array $sortMethods): array; - - /** - * @param list $conditions - * @param list $sortMethods - * - * @return Pagerfanta - */ - public function getEntitiesForPage(array $conditions, array $sortMethods, PagePagination $pagination): Pagerfanta; - /** * Deletes an entity identified by the given identifier and conditions. * * @param non-empty-string $entityIdentifier The entity's identifier. - * @param list $conditions Additional conditions for delete operation, all conditions must match. + * @param list $conditions Additional conditions for delete operation, all conditions must match. * @param non-empty-list $identifierPropertyPath Property path used for entity identification. * * @throws Exception If deletion or its side effects fail. @@ -71,8 +54,8 @@ public function deleteEntityByIdentifier(string $entityIdentifier, array $condit /** * @param non-empty-list $entities - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * * @return list */ @@ -80,14 +63,14 @@ public function reindexEntities(array $entities, array $conditions, array $sortM /** * @param TEntity $entity - * @param non-empty-list $conditions + * @param non-empty-list $conditions */ public function isMatchingEntity(object $entity, array $conditions): bool; /** * @param TEntity $entity * - * @param list $conditions + * @param list $conditions * * @throws Exception */ diff --git a/packages/jsonapi/src/InputHandling/SortMethodConverter.php b/packages/jsonapi/src/InputHandling/SortMethodConverter.php new file mode 100644 index 00000000..0b684645 --- /dev/null +++ b/packages/jsonapi/src/InputHandling/SortMethodConverter.php @@ -0,0 +1,59 @@ + $sortingTransformer + */ + public function __construct( + protected readonly JsonApiSortingParser $sortingTransformer, + protected readonly SortValidator $sortingValidator, + ) {} + + /** + * @template TSort + * + * @param SortMethodFactoryInterface $sortMethodFactory + * + * @return SortMethodConverter + */ + public static function createDefault(ValidatorInterface $validator, SortMethodFactoryInterface $sortMethodFactory) + { + $sortingTransformer = new JsonApiSortingParser($sortMethodFactory); + $sortingValidator = new SortValidator($validator); + + return new self($sortingTransformer, $sortingValidator); + } + + /** + * @param list $sortMethods + * + * @return list + */ + public function convertSortMethods(array $sortMethods): array + { + if ([] !== $sortMethods) { + $sortMethodsString = implode(',', array_map( + static fn(SortMethodInterface $sortMethod): string => $sortMethod->getAsString(), + $sortMethods + )); + $sortMethodsString = $this->sortingValidator->validateFormat($sortMethodsString); + $sortMethods = $this->sortingTransformer->createFromQueryParamValue($sortMethodsString); + } + + return $sortMethods; + } +} diff --git a/packages/jsonapi/src/Manager.php b/packages/jsonapi/src/Manager.php index 30f240d8..7fea71b8 100644 --- a/packages/jsonapi/src/Manager.php +++ b/packages/jsonapi/src/Manager.php @@ -24,31 +24,26 @@ use EDT\JsonApi\ResourceTypes\ListableTypeInterface; use EDT\JsonApi\ResourceTypes\UpdatableTypeInterface; use EDT\JsonApi\Utilities\NameBasedTypeProvider; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\NamedTypeInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use Webmozart\Assert\Assert; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ class Manager { /** - * @var array&PropertyReadableTypeInterface> + * @var array&PropertyReadableTypeInterface> */ protected array $getableTypes = []; /** - * @var array&PropertyReadableTypeInterface> + * @var array&PropertyReadableTypeInterface> */ protected array $listableTypes = []; /** - * @var array&PropertyReadableTypeInterface> + * @var array&PropertyReadableTypeInterface> */ protected array $updatableTypes = []; /** - * @var array&PropertyReadableTypeInterface> + * @var array&PropertyReadableTypeInterface> */ protected array $creatableTypes = []; /** @@ -120,7 +115,7 @@ public function setResourceIdAttribute(string $resourceIdAttribute): void } /** - * @param GetableTypeInterface&PropertyReadableTypeInterface $type + * @param GetableTypeInterface&PropertyReadableTypeInterface $type */ public function registerGetableType(GetableTypeInterface $type): void { @@ -129,7 +124,7 @@ public function registerGetableType(GetableTypeInterface $type): void } /** - * @param list&PropertyReadableTypeInterface> $types + * @param list&PropertyReadableTypeInterface> $types */ public function registerGetableTypes(array $types): void { @@ -137,7 +132,7 @@ public function registerGetableTypes(array $types): void } /** - * @param ListableTypeInterface&PropertyReadableTypeInterface $type + * @param ListableTypeInterface&PropertyReadableTypeInterface $type */ public function registerListableType(ListableTypeInterface $type): void { @@ -146,7 +141,7 @@ public function registerListableType(ListableTypeInterface $type): void } /** - * @param UpdatableTypeInterface&PropertyReadableTypeInterface $type + * @param UpdatableTypeInterface&PropertyReadableTypeInterface $type */ public function registerUpdatableType(UpdatableTypeInterface $type): void { @@ -155,7 +150,7 @@ public function registerUpdatableType(UpdatableTypeInterface $type): void } /** - * @param CreatableTypeInterface&PropertyReadableTypeInterface $type + * @param CreatableTypeInterface&PropertyReadableTypeInterface $type */ public function registerCreatableType(CreatableTypeInterface $type): void { @@ -171,7 +166,7 @@ public function registerDeletableType(DeletableTypeInterface&NamedTypeInterface } /** - * @param list&PropertyReadableTypeInterface> $types + * @param list&PropertyReadableTypeInterface> $types */ public function registerListableTypes(array $types): void { @@ -179,7 +174,7 @@ public function registerListableTypes(array $types): void } /** - * @param list&PropertyReadableTypeInterface> $types + * @param list&PropertyReadableTypeInterface> $types */ public function registerUpdatableTypes(array $types): void { @@ -187,7 +182,7 @@ public function registerUpdatableTypes(array $types): void } /** - * @param list&PropertyReadableTypeInterface> $types + * @param list&PropertyReadableTypeInterface> $types */ public function registerCreatableTypes(array $types): void { @@ -214,7 +209,7 @@ public function registerDeletableTypes(array $types): void * * Do not call this method if your type is registered as directly available via the other register methods. * - * @param PropertyReadableTypeInterface&NamedTypeInterface $type + * @param PropertyReadableTypeInterface&NamedTypeInterface $type */ public function registerType(PropertyReadableTypeInterface&NamedTypeInterface $type): void { @@ -233,7 +228,7 @@ public function registerType(PropertyReadableTypeInterface&NamedTypeInterface $t * * Do not call this method if your types are registered as directly available via the other register methods. * - * @param list&NamedTypeInterface> $type + * @param list&NamedTypeInterface> $type */ public function registerTypes(array $type): void { @@ -258,9 +253,6 @@ public function createOpenApiDocumentBuilder(): OpenApiDocumentBuilder ); } - /** - * @return GetProcessor - */ public function createGetProcessor(GetProcessorConfigInterface $config): GetProcessor { return new GetProcessor( @@ -272,11 +264,6 @@ public function createGetProcessor(GetProcessorConfigInterface $config): GetProc ); } - /** - * @param ListProcessorConfigInterface $config - * - * @return ListProcessor - */ public function createListProcessor(ListProcessorConfigInterface $config): ListProcessor { return new ListProcessor( @@ -294,9 +281,6 @@ public function createListProcessor(ListProcessorConfigInterface $config): ListP ); } - /** - * @return CreationProcessor - */ public function createCreationProcessor(CreationProcessorConfigInterface $config): CreationProcessor { return new CreationProcessor( @@ -311,9 +295,6 @@ public function createCreationProcessor(CreationProcessorConfigInterface $config ); } - /** - * @return UpdateProcessor - */ public function createUpdateProcessor(UpdateProcessorConfigInterface $config): UpdateProcessor { return new UpdateProcessor( diff --git a/packages/jsonapi/src/OutputHandling/DynamicTransformer.php b/packages/jsonapi/src/OutputHandling/DynamicTransformer.php index 523be330..df76c8a4 100644 --- a/packages/jsonapi/src/OutputHandling/DynamicTransformer.php +++ b/packages/jsonapi/src/OutputHandling/DynamicTransformer.php @@ -5,7 +5,7 @@ namespace EDT\JsonApi\OutputHandling; use EDT\JsonApi\RequestHandling\MessageFormatter; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\Querying\Utilities\PathConverterTrait; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\PropertyBehavior\Attribute\AttributeReadabilityInterface; @@ -46,23 +46,23 @@ * properties that do not exist in the entity to be transformed, then the behavior is undefined. * * @template TEntity of object - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface */ class DynamicTransformer extends TransformerAbstract { + use PathConverterTrait; + /** * @var array> */ private array $attributeReadabilities; /** - * @var array> + * @var array> */ private array $toOneRelationshipReadabilities; /** - * @var array> + * @var array> */ private array $toManyRelationshipReadabilities; @@ -74,7 +74,7 @@ class DynamicTransformer extends TransformerAbstract /** * @param non-empty-string $typeName * @param class-string $entityClass - * @param ResourceReadability $readability + * @param ResourceReadability $readability * * @throws InvalidArgumentException */ @@ -188,7 +188,7 @@ public function __call(string $methodName, array $arguments): Collection|Item|Nu } /** - * @param ToOneRelationshipReadabilityInterface $readability + * @param ToOneRelationshipReadabilityInterface $readability * @param TEntity $entity * * @throws InvalidArgumentException @@ -208,7 +208,7 @@ protected function retrieveRelationshipItem( } /** - * @param ToManyRelationshipReadabilityInterface $readability + * @param ToManyRelationshipReadabilityInterface $readability * @param TEntity $entity * * @throws InvalidArgumentException @@ -225,7 +225,7 @@ protected function retrieveRelationshipCollection( } /** - * @param TransferableTypeInterface $relationshipType + * @param TransferableTypeInterface $relationshipType * * @throws InvalidArgumentException */ @@ -289,7 +289,7 @@ public function validateIncludes(Scope $scope): void // continue if the include was not requested for this specific type continue; } - $requestedIncludePath = explode('.', $requestedInclude); + $requestedIncludePath = self::pathToArray($requestedInclude); $firstSegment = array_shift($requestedIncludePath); Assert::stringNotEmpty($firstSegment); if (!in_array($firstSegment, $this->availableIncludes, true)) { diff --git a/packages/jsonapi/src/OutputHandling/PropertyReadableTypeProviderInterface.php b/packages/jsonapi/src/OutputHandling/PropertyReadableTypeProviderInterface.php index d0aeb478..e0cec7c7 100644 --- a/packages/jsonapi/src/OutputHandling/PropertyReadableTypeProviderInterface.php +++ b/packages/jsonapi/src/OutputHandling/PropertyReadableTypeProviderInterface.php @@ -4,20 +4,19 @@ namespace EDT\JsonApi\OutputHandling; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; interface PropertyReadableTypeProviderInterface { /** * @param non-empty-string $typeName - * @return PropertyReadableTypeInterface + * @return PropertyReadableTypeInterface */ public function getType(string $typeName): PropertyReadableTypeInterface; /** * @param non-empty-string $typeName - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type */ public function addType(string $typeName, PropertyReadableTypeInterface $type): void; } diff --git a/packages/jsonapi/src/OutputHandling/ResponseFactory.php b/packages/jsonapi/src/OutputHandling/ResponseFactory.php index 17ecd347..5040488c 100644 --- a/packages/jsonapi/src/OutputHandling/ResponseFactory.php +++ b/packages/jsonapi/src/OutputHandling/ResponseFactory.php @@ -7,13 +7,11 @@ use EDT\JsonApi\InputHandling\FractalManagerFactory; use EDT\JsonApi\RequestHandling\RequestHeader; use EDT\JsonApi\RequestHandling\UrlParameter; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use League\Fractal\Resource\ResourceAbstract; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Webmozart\Assert\Assert; use function array_key_exists; use const JSON_OBJECT_AS_ARRAY; @@ -29,7 +27,7 @@ public function __construct( ) {} /** - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * @param int<100,599> $statusCode */ public function createResourceResponse( diff --git a/packages/jsonapi/src/PropertyConfig/AttributeConfigInterface.php b/packages/jsonapi/src/PropertyConfig/AttributeConfigInterface.php index efe2ed25..046ce641 100644 --- a/packages/jsonapi/src/PropertyConfig/AttributeConfigInterface.php +++ b/packages/jsonapi/src/PropertyConfig/AttributeConfigInterface.php @@ -4,15 +4,13 @@ namespace EDT\JsonApi\PropertyConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\Attribute\AttributeReadabilityInterface; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-extends PropertyConfigInterface + * @template-extends PropertyConfigInterface */ interface AttributeConfigInterface extends PropertyConfigInterface { @@ -22,7 +20,7 @@ interface AttributeConfigInterface extends PropertyConfigInterface public function getReadability(): ?AttributeReadabilityInterface; /** - * @return list> + * @return list> */ public function getUpdateBehaviors(): array; } diff --git a/packages/jsonapi/src/PropertyConfig/Builder/AbstractPropertyConfigBuilder.php b/packages/jsonapi/src/PropertyConfig/Builder/AbstractPropertyConfigBuilder.php index a66deb57..fc75ff42 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/AbstractPropertyConfigBuilder.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/AbstractPropertyConfigBuilder.php @@ -5,7 +5,6 @@ namespace EDT\JsonApi\PropertyConfig\Builder; use EDT\Querying\Contracts\PathException; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ContentField; use Webmozart\Assert\Assert; @@ -21,13 +20,12 @@ * entity exist. * * @template TEntity of object - * @template TCondition of PathsBasedInterface * @template TValue * @template TConstructorBehaviorFactory of object * @template TPostConstructorBehaviorFactory of object * @template TUpdateBehaviorFactory of object * - * @template-implements AttributeOrRelationshipBuilderInterface + * @template-implements AttributeOrRelationshipBuilderInterface */ abstract class AbstractPropertyConfigBuilder implements AttributeOrRelationshipBuilderInterface { diff --git a/packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilder.php b/packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilder.php index a0829f2f..9a232ccf 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilder.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilder.php @@ -8,7 +8,6 @@ use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\PropertyConfig\AttributeConfigInterface; use EDT\JsonApi\PropertyConfig\DtoAttributeConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Querying\PropertyPaths\NonRelationshipLink; use EDT\Querying\PropertyPaths\PropertyLinkInterface; @@ -26,12 +25,11 @@ use EDT\Wrapping\Utilities\AttributeTypeResolverInterface; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-implements AttributeConfigBuilderInterface - * @template-implements BuildableInterface> - * @template-extends AbstractPropertyConfigBuilder|null, ConstructorBehaviorFactoryInterface, PropertyUpdatabilityFactoryInterface, PropertyUpdatabilityFactoryInterface> + * @template-implements AttributeConfigBuilderInterface + * @template-implements BuildableInterface> + * @template-extends AbstractPropertyConfigBuilder|null, ConstructorBehaviorFactoryInterface, PropertyUpdatabilityFactoryInterface, PropertyUpdatabilityFactoryInterface> */ class AttributeConfigBuilder extends AbstractPropertyConfigBuilder @@ -213,7 +211,7 @@ protected function getConstructorBehaviors(): array } /** - * @return list> + * @return list> */ protected function getUpdateBehaviors(): array { diff --git a/packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilderInterface.php b/packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilderInterface.php index 34eb2fba..f70e0b10 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilderInterface.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilderInterface.php @@ -4,7 +4,7 @@ namespace EDT\JsonApi\PropertyConfig\Builder; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorFactoryInterface; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityFactoryInterface; @@ -13,15 +13,14 @@ * * Besides that, its type itself can be used to denote a resource attribute. * - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-extends AttributeOrRelationshipBuilderInterface|null, ConstructorBehaviorFactoryInterface, PropertyUpdatabilityFactoryInterface, PropertyUpdatabilityFactoryInterface> + * @template-extends AttributeOrRelationshipBuilderInterface|null, ConstructorBehaviorFactoryInterface, PropertyUpdatabilityFactoryInterface, PropertyUpdatabilityFactoryInterface> */ interface AttributeConfigBuilderInterface extends AttributeOrRelationshipBuilderInterface { /** - * @param list $entityConditions + * @param list $entityConditions * @param null|callable(TEntity, simple_primitive|array|null): list $updateCallback * * @return $this diff --git a/packages/jsonapi/src/PropertyConfig/Builder/AttributeOrRelationshipBuilderInterface.php b/packages/jsonapi/src/PropertyConfig/Builder/AttributeOrRelationshipBuilderInterface.php index ce97a5fe..041e6041 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/AttributeOrRelationshipBuilderInterface.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/AttributeOrRelationshipBuilderInterface.php @@ -4,20 +4,19 @@ namespace EDT\JsonApi\PropertyConfig\Builder; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\DefaultField; -use EDT\Querying\Contracts\PathsBasedInterface; /** * This interface defines configuration options that are available for attributes and relationships, but *not* the ID. * * @template TEntity of object - * @template TCondition of PathsBasedInterface * @template TValue the type of value corresponding to the resource property * @template TConstructorBehaviorFactory of object * @template TPostConstructorBehaviorFactory of object * @template TUpdateBehaviorFactory of object * - * @template-extends PropertyConfigBuilderInterface + * @template-extends PropertyConfigBuilderInterface */ interface AttributeOrRelationshipBuilderInterface extends PropertyConfigBuilderInterface { @@ -59,7 +58,7 @@ public function removeAllUpdateBehaviors(): self; * provided on that call. How the path is handled to set the value provided in the request depends on the * {@link PropertyAccessorInterface} implementation configured. * - * @param list $entityConditions + * @param list $entityConditions * * @return $this */ diff --git a/packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilder.php b/packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilder.php index c436e0fd..71911ee7 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilder.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilder.php @@ -8,7 +8,6 @@ use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\PropertyConfig\DtoIdentifierConfig; use EDT\JsonApi\PropertyConfig\IdentifierConfigInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Querying\PropertyPaths\NonRelationshipLink; use EDT\Wrapping\Contracts\ContentField; @@ -25,9 +24,8 @@ /** * @template TEntity of object - * @template TCondition of PathsBasedInterface * - * @template-implements IdentifierConfigBuilderInterface + * @template-implements IdentifierConfigBuilderInterface */ class IdentifierConfigBuilder implements IdentifierConfigBuilderInterface { diff --git a/packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilderInterface.php b/packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilderInterface.php index 73ab796e..cbea9dc6 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilderInterface.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilderInterface.php @@ -4,7 +4,6 @@ namespace EDT\JsonApi\PropertyConfig\Builder; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\Identifier\Factory\IdentifierConstructorBehaviorFactoryInterface; use EDT\Wrapping\PropertyBehavior\Identifier\Factory\IdentifierPostConstructorBehaviorFactoryInterface; @@ -14,9 +13,8 @@ * Besides that, its type itself can be used to denote a to-one relationship property. * * @template TEntity of object - * @template TCondition of PathsBasedInterface * - * @template-extends PropertyConfigBuilderInterface + * @template-extends PropertyConfigBuilderInterface */ interface IdentifierConfigBuilderInterface extends PropertyConfigBuilderInterface { diff --git a/packages/jsonapi/src/PropertyConfig/Builder/PropertyConfigBuilderInterface.php b/packages/jsonapi/src/PropertyConfig/Builder/PropertyConfigBuilderInterface.php index 24056e86..dec173e6 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/PropertyConfigBuilderInterface.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/PropertyConfigBuilderInterface.php @@ -4,8 +4,8 @@ namespace EDT\JsonApi\PropertyConfig\Builder; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\OptionalField; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyPathInterface; /** @@ -13,7 +13,6 @@ * but the resource ID too. * * @template TEntity of object - * @template TCondition of PathsBasedInterface * @template TValue */ interface PropertyConfigBuilderInterface @@ -129,7 +128,7 @@ public function setSortable(): self; public function setNonSortable(): self; /** - * @param list $entityConditions + * @param list $entityConditions * * @return $this */ diff --git a/packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilder.php b/packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilder.php index 46a204eb..f1ad4c9b 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilder.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilder.php @@ -8,7 +8,6 @@ use EDT\JsonApi\ApiDocumentation\DefaultInclude; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; use EDT\Querying\PropertyPaths\RelationshipLink; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; @@ -22,25 +21,23 @@ use Webmozart\Assert\Assert; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * @template TValue of list|TRelationship|null * @template TReadability of RelationshipReadabilityInterface * - * @template-extends AbstractPropertyConfigBuilder, RelationshipSetBehaviorFactoryInterface, RelationshipSetBehaviorFactoryInterface> - * @template-implements RelationshipConfigBuilderInterface + * @template-extends AbstractPropertyConfigBuilder, RelationshipSetBehaviorFactoryInterface> + * @template-implements RelationshipConfigBuilderInterface */ abstract class RelationshipConfigBuilder extends AbstractPropertyConfigBuilder implements RelationshipConfigBuilderInterface { /** - * @var null|callable(non-empty-string, non-empty-list, class-string, ResourceTypeInterface|ResourceTypeProviderInterface): TReadability + * @var null|callable(non-empty-string, non-empty-list, class-string, ResourceTypeInterface|ResourceTypeProviderInterface): TReadability */ protected $readabilityFactory; /** - * @var ResourceTypeInterface|ResourceTypeProviderInterface|null + * @var ResourceTypeInterface|ResourceTypeProviderInterface|null */ protected ResourceTypeInterface|ResourceTypeProviderInterface|null $relationshipType = null; @@ -88,7 +85,7 @@ public function addPathUpdateBehavior(array $entityConditions = [], array $relat } /** - * @param FilteringTypeInterface|ResourceTypeProviderInterface $relationshipType + * @param FilteringTypeInterface|ResourceTypeProviderInterface $relationshipType */ protected function getFilterLink(FilteringTypeInterface|ResourceTypeProviderInterface $relationshipType): ?PropertyLinkInterface { @@ -103,7 +100,7 @@ protected function getFilterLink(FilteringTypeInterface|ResourceTypeProviderInte } /** - * @param SortingTypeInterface|ResourceTypeProviderInterface $relationshipType + * @param SortingTypeInterface|ResourceTypeProviderInterface $relationshipType */ protected function getSortLink(SortingTypeInterface|ResourceTypeProviderInterface $relationshipType): ?PropertyLinkInterface { @@ -118,7 +115,7 @@ protected function getSortLink(SortingTypeInterface|ResourceTypeProviderInterfac } /** - * @return list> + * @return list> */ protected function getPostConstructorBehaviors(): array { @@ -146,7 +143,7 @@ protected function getConstructorBehaviors(): array } /** - * @return list> + * @return list> */ protected function getUpdateBehaviors(): array { @@ -161,7 +158,7 @@ protected function getUpdateBehaviors(): array } /** - * @return ResourceTypeInterface|ResourceTypeProviderInterface + * @return ResourceTypeInterface|ResourceTypeProviderInterface */ protected function getFinalRelationshipType(): ResourceTypeInterface|ResourceTypeProviderInterface { @@ -171,7 +168,7 @@ protected function getFinalRelationshipType(): ResourceTypeInterface|ResourceTyp } /** - * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType + * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType * * @return TReadability|null */ diff --git a/packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilderInterface.php b/packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilderInterface.php index 036500b2..3f871f7d 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilderInterface.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilderInterface.php @@ -4,11 +4,11 @@ namespace EDT\JsonApi\PropertyConfig\Builder; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\ApiDocumentation\DefaultField; use EDT\JsonApi\ApiDocumentation\DefaultInclude; use EDT\JsonApi\ApiDocumentation\OptionalField; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipConstructorBehaviorFactoryInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipSetBehaviorFactoryInterface; @@ -16,18 +16,16 @@ /** * This interface define configuration options that are available to-one and to-many relationships. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * @template TValue of list|TRelationship|null the value of the property * - * @template-extends AttributeOrRelationshipBuilderInterface, RelationshipSetBehaviorFactoryInterface, RelationshipSetBehaviorFactoryInterface> + * @template-extends AttributeOrRelationshipBuilderInterface, RelationshipSetBehaviorFactoryInterface> */ interface RelationshipConfigBuilderInterface extends AttributeOrRelationshipBuilderInterface { /** - * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType $relationshipType + * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType $relationshipType * * @return $this */ @@ -65,8 +63,8 @@ public function readable( ): self; /** - * @param list $entityConditions - * @param list $relationshipConditions + * @param list $entityConditions + * @param list $relationshipConditions * @param null|callable(TEntity, TValue): list $updateCallback * * @return $this @@ -78,7 +76,7 @@ public function updatable(array $entityConditions = [], array $relationshipCondi /** * @param null|callable(TEntity, TValue): list $postConstructorCallback * @param non-empty-string|null $customConstructorArgumentName the name of the constructor parameter, or `null` if it is the same as the name of this property - * @param list $relationshipConditions + * @param list $relationshipConditions * * @return $this * @@ -93,16 +91,16 @@ public function initializable( ): self; /** - * @param list $entityConditions - * @param list $relationshipConditions + * @param list $entityConditions + * @param list $relationshipConditions * * @return $this */ public function addPathUpdateBehavior(array $entityConditions = [], array $relationshipConditions = []): self; /** - * @param list $entityConditions - * @param list $relationshipConditions + * @param list $entityConditions + * @param list $relationshipConditions */ public function addPathCreationBehavior(OptionalField $optional = OptionalField::NO, array $entityConditions = [], array $relationshipConditions = []): self; } diff --git a/packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilder.php b/packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilder.php index 7a376bc5..59a6e653 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilder.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilder.php @@ -8,7 +8,6 @@ use EDT\JsonApi\PropertyConfig\DtoToManyRelationshipConfig; use EDT\JsonApi\PropertyConfig\ToManyRelationshipConfigInterface; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\CallbackToManyRelationshipReadability; @@ -19,14 +18,12 @@ use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\ToManyRelationshipReadabilityInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends RelationshipConfigBuilder, ToManyRelationshipReadabilityInterface> - * @template-implements ToManyRelationshipConfigBuilderInterface - * @template-implements BuildableInterface> + * @template-extends RelationshipConfigBuilder, ToManyRelationshipReadabilityInterface> + * @template-implements ToManyRelationshipConfigBuilderInterface + * @template-implements BuildableInterface> */ class ToManyRelationshipConfigBuilder extends RelationshipConfigBuilder @@ -112,9 +109,9 @@ public function __construct( * @param non-empty-string $name * @param non-empty-list $propertyPath * @param class-string $entityClass - * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType + * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType * - * @return ToManyRelationshipReadabilityInterface + * @return ToManyRelationshipReadabilityInterface */ public function __invoke(string $name, array $propertyPath, string $entityClass, ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType): ToManyRelationshipReadabilityInterface { diff --git a/packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilderInterface.php b/packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilderInterface.php index ab0a326e..48e76090 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilderInterface.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilderInterface.php @@ -4,19 +4,15 @@ namespace EDT\JsonApi\PropertyConfig\Builder; -use EDT\Querying\Contracts\PathsBasedInterface; - /** * This interface defines configuration options that only available for to-many relationships. * * Besides that, its type itself can be used to denote a to-many relationship property. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends RelationshipConfigBuilderInterface> + * @template-extends RelationshipConfigBuilderInterface> */ interface ToManyRelationshipConfigBuilderInterface extends RelationshipConfigBuilderInterface { diff --git a/packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilder.php b/packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilder.php index 3d096e7c..84339763 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilder.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilder.php @@ -8,7 +8,6 @@ use EDT\JsonApi\PropertyConfig\DtoToOneRelationshipConfig; use EDT\JsonApi\PropertyConfig\ToOneRelationshipConfigInterface; use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; use EDT\Wrapping\PropertyBehavior\Relationship\ToOne\CallbackToOneRelationshipReadability; @@ -19,14 +18,12 @@ use EDT\Wrapping\PropertyBehavior\Relationship\ToOne\ToOneRelationshipReadabilityInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends RelationshipConfigBuilder> - * @template-implements ToOneRelationshipConfigBuilderInterface - * @template-implements BuildableInterface> + * @template-extends RelationshipConfigBuilder> + * @template-implements ToOneRelationshipConfigBuilderInterface + * @template-implements BuildableInterface> */ class ToOneRelationshipConfigBuilder extends RelationshipConfigBuilder @@ -112,9 +109,9 @@ public function __construct( * @param non-empty-string $name * @param non-empty-list $propertyPath * @param class-string $entityClass - * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType + * @param ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType * - * @return ToOneRelationshipReadabilityInterface + * @return ToOneRelationshipReadabilityInterface */ public function __invoke(string $name, array $propertyPath, string $entityClass, ResourceTypeInterface|ResourceTypeProviderInterface $relationshipType): ToOneRelationshipReadabilityInterface { diff --git a/packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilderInterface.php b/packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilderInterface.php index d7751f2d..8042dee2 100644 --- a/packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilderInterface.php +++ b/packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilderInterface.php @@ -4,19 +4,15 @@ namespace EDT\JsonApi\PropertyConfig\Builder; -use EDT\Querying\Contracts\PathsBasedInterface; - /** * This interface defines configuration options that only available for to-one relationships. * * Besides that, its type itself can be used to denote a to-one relationship property. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends RelationshipConfigBuilderInterface + * @template-extends RelationshipConfigBuilderInterface */ interface ToOneRelationshipConfigBuilderInterface extends RelationshipConfigBuilderInterface { diff --git a/packages/jsonapi/src/PropertyConfig/DtoAttributeConfig.php b/packages/jsonapi/src/PropertyConfig/DtoAttributeConfig.php index ca538a19..27704de1 100644 --- a/packages/jsonapi/src/PropertyConfig/DtoAttributeConfig.php +++ b/packages/jsonapi/src/PropertyConfig/DtoAttributeConfig.php @@ -4,7 +4,6 @@ namespace EDT\JsonApi\PropertyConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; use EDT\Wrapping\PropertyBehavior\Attribute\AttributeReadabilityInterface; use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; @@ -12,16 +11,15 @@ use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object * - * @template-implements AttributeConfigInterface + * @template-implements AttributeConfigInterface */ class DtoAttributeConfig implements AttributeConfigInterface { /** * @param AttributeReadabilityInterface|null $readability - * @param list> $updateBehaviors + * @param list> $updateBehaviors * @param list> $postConstructorBehaviors * @param list $constructorBehaviors */ diff --git a/packages/jsonapi/src/PropertyConfig/DtoToManyRelationshipConfig.php b/packages/jsonapi/src/PropertyConfig/DtoToManyRelationshipConfig.php index e4456bb7..1f2ac52c 100644 --- a/packages/jsonapi/src/PropertyConfig/DtoToManyRelationshipConfig.php +++ b/packages/jsonapi/src/PropertyConfig/DtoToManyRelationshipConfig.php @@ -4,7 +4,6 @@ namespace EDT\JsonApi\PropertyConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; use EDT\Wrapping\PropertyBehavior\PropertySetBehaviorInterface; @@ -12,18 +11,16 @@ use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\ToManyRelationshipReadabilityInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements ToManyRelationshipConfigInterface + * @template-implements ToManyRelationshipConfigInterface */ class DtoToManyRelationshipConfig implements ToManyRelationshipConfigInterface { /** - * @param ToManyRelationshipReadabilityInterface|null $readability - * @param list> $updateBehaviors + * @param ToManyRelationshipReadabilityInterface|null $readability + * @param list> $updateBehaviors * @param list> $postConstructorBehaviors * @param list $constructorBehaviors */ diff --git a/packages/jsonapi/src/PropertyConfig/DtoToOneRelationshipConfig.php b/packages/jsonapi/src/PropertyConfig/DtoToOneRelationshipConfig.php index b52edd11..8da17463 100644 --- a/packages/jsonapi/src/PropertyConfig/DtoToOneRelationshipConfig.php +++ b/packages/jsonapi/src/PropertyConfig/DtoToOneRelationshipConfig.php @@ -4,7 +4,6 @@ namespace EDT\JsonApi\PropertyConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; use EDT\Wrapping\PropertyBehavior\PropertySetBehaviorInterface; @@ -12,18 +11,16 @@ use EDT\Wrapping\PropertyBehavior\Relationship\ToOne\ToOneRelationshipReadabilityInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-implements ToOneRelationshipConfigInterface + * @template-implements ToOneRelationshipConfigInterface */ class DtoToOneRelationshipConfig implements ToOneRelationshipConfigInterface { /** - * @param ToOneRelationshipReadabilityInterface|null $readability - * @param list> $updateBehaviors + * @param ToOneRelationshipReadabilityInterface|null $readability + * @param list> $updateBehaviors * @param list> $postConstructorBehaviors * @param list $constructorBehaviors * @param PropertyLinkInterface|null $filterLink diff --git a/packages/jsonapi/src/PropertyConfig/PropertyConfigInterface.php b/packages/jsonapi/src/PropertyConfig/PropertyConfigInterface.php index cf0283a1..efae3435 100644 --- a/packages/jsonapi/src/PropertyConfig/PropertyConfigInterface.php +++ b/packages/jsonapi/src/PropertyConfig/PropertyConfigInterface.php @@ -4,13 +4,11 @@ namespace EDT\JsonApi\PropertyConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; use EDT\Wrapping\PropertyBehavior\PropertySetBehaviorInterface; /** - * @template TCondition of PathsBasedInterface * @template TEntity of object */ interface PropertyConfigInterface diff --git a/packages/jsonapi/src/PropertyConfig/RelationshipConfigInterface.php b/packages/jsonapi/src/PropertyConfig/RelationshipConfigInterface.php index 73c15d1e..58e0cbbe 100644 --- a/packages/jsonapi/src/PropertyConfig/RelationshipConfigInterface.php +++ b/packages/jsonapi/src/PropertyConfig/RelationshipConfigInterface.php @@ -4,17 +4,14 @@ namespace EDT\JsonApi\PropertyConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\PropertySetBehaviorInterface; use EDT\Wrapping\PropertyBehavior\Relationship\RelationshipSetBehaviorInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends PropertyConfigInterface + * @template-extends PropertyConfigInterface */ interface RelationshipConfigInterface extends PropertyConfigInterface { @@ -24,7 +21,7 @@ interface RelationshipConfigInterface extends PropertyConfigInterface public function getPostConstructorBehaviors(): array; /** - * @return list> + * @return list> */ public function getUpdateBehaviors(): array; } diff --git a/packages/jsonapi/src/PropertyConfig/ToManyRelationshipConfigInterface.php b/packages/jsonapi/src/PropertyConfig/ToManyRelationshipConfigInterface.php index 19b47db1..daaa02ff 100644 --- a/packages/jsonapi/src/PropertyConfig/ToManyRelationshipConfigInterface.php +++ b/packages/jsonapi/src/PropertyConfig/ToManyRelationshipConfigInterface.php @@ -4,21 +4,18 @@ namespace EDT\JsonApi\PropertyConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\Relationship\ToMany\ToManyRelationshipReadabilityInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends RelationshipConfigInterface + * @template-extends RelationshipConfigInterface */ interface ToManyRelationshipConfigInterface extends RelationshipConfigInterface { /** - * @return ToManyRelationshipReadabilityInterface|null + * @return ToManyRelationshipReadabilityInterface|null */ public function getReadability(): ?ToManyRelationshipReadabilityInterface; diff --git a/packages/jsonapi/src/PropertyConfig/ToOneRelationshipConfigInterface.php b/packages/jsonapi/src/PropertyConfig/ToOneRelationshipConfigInterface.php index 65584a69..c9d66101 100644 --- a/packages/jsonapi/src/PropertyConfig/ToOneRelationshipConfigInterface.php +++ b/packages/jsonapi/src/PropertyConfig/ToOneRelationshipConfigInterface.php @@ -4,21 +4,18 @@ namespace EDT\JsonApi\PropertyConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\Relationship\ToOne\ToOneRelationshipReadabilityInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * @template TRelationship of object * - * @template-extends RelationshipConfigInterface + * @template-extends RelationshipConfigInterface */ interface ToOneRelationshipConfigInterface extends RelationshipConfigInterface { /** - * @return ToOneRelationshipReadabilityInterface|null + * @return ToOneRelationshipReadabilityInterface|null */ public function getReadability(): ?ToOneRelationshipReadabilityInterface; } diff --git a/packages/jsonapi/src/RequestHandling/FilterParserInterface.php b/packages/jsonapi/src/RequestHandling/FilterParserInterface.php index b53cb209..cfe33bfb 100644 --- a/packages/jsonapi/src/RequestHandling/FilterParserInterface.php +++ b/packages/jsonapi/src/RequestHandling/FilterParserInterface.php @@ -4,11 +4,9 @@ namespace EDT\JsonApi\RequestHandling; -use EDT\Querying\Contracts\PathsBasedInterface; - /** * @template TFilter - * @template TCondition of PathsBasedInterface + * @template TCondition */ interface FilterParserInterface { diff --git a/packages/jsonapi/src/RequestHandling/JsonApiSortingParser.php b/packages/jsonapi/src/RequestHandling/JsonApiSortingParser.php index 3d1c8226..8fb3ccbc 100644 --- a/packages/jsonapi/src/RequestHandling/JsonApiSortingParser.php +++ b/packages/jsonapi/src/RequestHandling/JsonApiSortingParser.php @@ -5,17 +5,19 @@ namespace EDT\JsonApi\RequestHandling; use EDT\Querying\Contracts\PathException; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\SortMethodFactoryInterface; use EDT\Querying\Contracts\SortMethodInterface; +use EDT\Querying\Utilities\PathConverterTrait; use InvalidArgumentException; use Webmozart\Assert\Assert; /** - * @template TSorting of PathsBasedInterface + * @template TSorting */ class JsonApiSortingParser { + use PathConverterTrait; + /** * @param SortMethodFactoryInterface $sortMethodFactory */ @@ -45,7 +47,7 @@ public function createFromQueryParamValue(string $sortQueryParamValue): array * @throws PathException * @throws InvalidArgumentException */ - protected function parseSortMethod(string $sortMethodRaw): PathsBasedInterface + protected function parseSortMethod(string $sortMethodRaw) { Assert::stringNotEmpty($sortMethodRaw); @@ -62,10 +64,10 @@ protected function parseSortMethod(string $sortMethodRaw): PathsBasedInterface * * @throws PathException */ - protected function parseNegativeDirection(string $sortMethodRaw): PathsBasedInterface + protected function parseNegativeDirection(string $sortMethodRaw) { $pathString = substr($sortMethodRaw, 1); - $pathArray = $this->toPathArray($pathString); + $pathArray = static::inputPathToArray($pathString); return $this->sortMethodFactory->propertyDescending($pathArray); } @@ -76,9 +78,9 @@ protected function parseNegativeDirection(string $sortMethodRaw): PathsBasedInte * * @throws PathException */ - protected function parsePositiveDirection(string $sortMethodRaw): PathsBasedInterface + protected function parsePositiveDirection(string $sortMethodRaw) { - $pathArray = $this->toPathArray($sortMethodRaw); + $pathArray = static::pathToArray($sortMethodRaw); return $this->sortMethodFactory->propertyAscending($pathArray); } @@ -89,17 +91,4 @@ protected function isNegativeDirection(string $sortMethodRaw): bool { return 0 === strncmp($sortMethodRaw, '-', 1); } - - /** - * @return non-empty-list - * - * @throws InvalidArgumentException - */ - protected function toPathArray(string $pathString): array - { - $path = explode('.', $pathString); - Assert::allStringNotEmpty($path, "Invalid path `$pathString`, contains empty segments."); - - return $path; - } } diff --git a/packages/jsonapi/src/RequestHandling/RequestWithBody.php b/packages/jsonapi/src/RequestHandling/RequestWithBody.php index bbd1d635..ef91d521 100644 --- a/packages/jsonapi/src/RequestHandling/RequestWithBody.php +++ b/packages/jsonapi/src/RequestHandling/RequestWithBody.php @@ -4,17 +4,11 @@ namespace EDT\JsonApi\RequestHandling; -use EDT\JsonApi\RequestHandling\Body\CreationRequestBody; -use EDT\JsonApi\RequestHandling\Body\UpdateRequestBody; use EDT\JsonApi\Requests\RequestException; use EDT\JsonApi\Validation\Patterns; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ContentField; -use EDT\Wrapping\Contracts\TypeProviderInterface; use JsonException; -use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Exception\ValidationFailedException; use Symfony\Component\Validator\Validator\ValidatorInterface; diff --git a/packages/jsonapi/src/Requests/CreationProcessor.php b/packages/jsonapi/src/Requests/CreationProcessor.php index 386415d9..61362961 100644 --- a/packages/jsonapi/src/Requests/CreationProcessor.php +++ b/packages/jsonapi/src/Requests/CreationProcessor.php @@ -9,7 +9,6 @@ use EDT\JsonApi\RequestHandling\RequestConstraintFactory; use EDT\JsonApi\RequestHandling\RequestWithBody; use EDT\JsonApi\ResourceTypes\CreatableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use Exception; use League\Fractal\Resource\Item; @@ -18,17 +17,13 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Validator\Validator\ValidatorInterface; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ class CreationProcessor { use EmptyResponseTrait; use ProcessorTrait; /** - * @param array&PropertyReadableTypeInterface> $creatableTypes + * @param array&PropertyReadableTypeInterface> $creatableTypes * @param non-empty-string $resourceTypeAttribute * @param non-empty-string $resourceIdAttribute * @param int<1,8192> $maxBodyNestingDepth see {@link RequestWithBody::getRequestBody()} @@ -55,7 +50,7 @@ public function createResponse(Request $request): Response } /** - * @param CreatableTypeInterface $type + * @param CreatableTypeInterface $type * * @throws Exception */ diff --git a/packages/jsonapi/src/Requests/CreationRequest.php b/packages/jsonapi/src/Requests/CreationRequest.php index ee66859e..79cfb3a2 100644 --- a/packages/jsonapi/src/Requests/CreationRequest.php +++ b/packages/jsonapi/src/Requests/CreationRequest.php @@ -11,7 +11,6 @@ use EDT\JsonApi\RequestHandling\RequestConstraintFactory; use EDT\JsonApi\RequestHandling\RequestWithBody; use EDT\JsonApi\ResourceTypes\CreatableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ContentField; use Exception; use League\Fractal\Resource\Item; @@ -19,10 +18,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Validator\Validator\ValidatorInterface; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ class CreationRequest extends RequestWithBody { /** @@ -52,7 +47,7 @@ public function __construct( * * TODO: test if the statement above is compatible with the specification and actually true regarding the libraries behavior * - * @param CreatableTypeInterface $type + * @param CreatableTypeInterface $type * * @throws Exception */ diff --git a/packages/jsonapi/src/Requests/DefaultProcessorConfig.php b/packages/jsonapi/src/Requests/DefaultProcessorConfig.php index d672b638..b85c2b56 100644 --- a/packages/jsonapi/src/Requests/DefaultProcessorConfig.php +++ b/packages/jsonapi/src/Requests/DefaultProcessorConfig.php @@ -4,8 +4,8 @@ namespace EDT\JsonApi\Requests; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; -use EDT\ConditionFactory\PathsBasedConditionGroupFactoryInterface; +use EDT\ConditionFactory\DrupalFilterInterface; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\InputHandling\FractalManagerFactory; use EDT\JsonApi\OutputHandling\PropertyReadableTypeProviderInterface; use EDT\JsonApi\OutputHandling\ResponseFactory; @@ -21,25 +21,16 @@ use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterValidator; use EDT\Querying\ConditionParsers\Drupal\PredefinedDrupalConditionFactory; -use EDT\Querying\Contracts\PathsBasedInterface; -use EDT\Querying\Contracts\SortMethodFactoryInterface; +use EDT\Querying\SortMethodFactories\SortMethodFactory; use EDT\Wrapping\Utilities\PropertyPathProcessorFactory; use EDT\Wrapping\Utilities\SchemaPathProcessor; use Psr\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Routing\Router; use Symfony\Component\Validator\Validator\ValidatorInterface; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - * - * @template-implements ListProcessorConfigInterface - */ class DefaultProcessorConfig implements GetProcessorConfigInterface, ListProcessorConfigInterface, CreationProcessorConfigInterface, UpdateProcessorConfigInterface, DeletionProcessorConfigInterface { /** - * @param PathsBasedConditionGroupFactoryInterface&PathsBasedConditionFactoryInterface $conditionFactory - * @param SortMethodFactoryInterface $sortMethodFactory * @param int<0,max> $fractalRecursionLimit * @param int<0,8192> $attributeValidationDepth * @param int<1,8192> $maxBodyNestingDepth see {@link RequestWithBody::getRequestBody()} @@ -48,8 +39,6 @@ public function __construct( protected readonly ValidatorInterface $validator, protected readonly EventDispatcherInterface $eventDispatcher, protected readonly Router $router, - protected readonly PathsBasedConditionGroupFactoryInterface&PathsBasedConditionFactoryInterface $conditionFactory, - protected readonly SortMethodFactoryInterface $sortMethodFactory, protected readonly int $fractalRecursionLimit = 20, protected readonly int $attributeValidationDepth = 20, protected readonly bool $attributeAllowAnythingBelowValidationDepth = true, @@ -57,16 +46,16 @@ public function __construct( ) {} /** - * @return DrupalFilterParser + * @return DrupalFilterParser */ public function getFilterTransformer(): DrupalFilterParser { - return new DrupalFilterParser($this->conditionFactory, $this->getDrupalConditionTransformer(), $this->getFilterValidator()); + return new DrupalFilterParser($this->getConditionFactory(), $this->getDrupalConditionTransformer(), $this->getFilterValidator()); } public function getSortingTransformer(): JsonApiSortingParser { - return new JsonApiSortingParser($this->sortMethodFactory); + return new JsonApiSortingParser($this->getSortMethodFactory()); } public function getPaginatorFactory(): PaginatorFactory @@ -113,11 +102,11 @@ public function getRequestConstraintFactory(): RequestConstraintFactory } /** - * @return PredefinedDrupalConditionFactory + * @return PredefinedDrupalConditionFactory */ protected function getDrupalConditionFactory(): PredefinedDrupalConditionFactory { - return new PredefinedDrupalConditionFactory($this->conditionFactory); + return new PredefinedDrupalConditionFactory($this->getConditionFactory()); } protected function getFractalManagerFactory(PropertyReadableTypeProviderInterface $typeProvider): FractalManagerFactory @@ -141,7 +130,7 @@ protected function getPropertyPathProcessorFactory(): PropertyPathProcessorFacto } /** - * @return DrupalConditionParser + * @return DrupalConditionParser */ protected function getDrupalConditionTransformer(): DrupalConditionParser { @@ -162,4 +151,14 @@ public function getMaxBodyNestingDepth(): int { return $this->maxBodyNestingDepth; } + + protected function getConditionFactory(): ConditionFactory + { + return new ConditionFactory(); + } + + protected function getSortMethodFactory(): SortMethodFactory + { + return new SortMethodFactory(); + } } diff --git a/packages/jsonapi/src/Requests/GetProcessor.php b/packages/jsonapi/src/Requests/GetProcessor.php index ca6ba93e..f597e4c1 100644 --- a/packages/jsonapi/src/Requests/GetProcessor.php +++ b/packages/jsonapi/src/Requests/GetProcessor.php @@ -6,7 +6,6 @@ use EDT\JsonApi\OutputHandling\ResponseFactory; use EDT\JsonApi\ResourceTypes\GetableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use Exception; use League\Fractal\Resource\Item; @@ -14,16 +13,12 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ class GetProcessor { use ProcessorTrait; /** - * @param array&PropertyReadableTypeInterface> $getableTypes + * @param array&PropertyReadableTypeInterface> $getableTypes * @param non-empty-string $resourceTypeAttribute * @param non-empty-string $resourceIdAttribute */ @@ -44,7 +39,7 @@ public function createResponse(Request $request): Response } /** - * @param GetableTypeInterface $type + * @param GetableTypeInterface $type * @param non-empty-string $resourceId * * @throws Exception diff --git a/packages/jsonapi/src/Requests/GetRequest.php b/packages/jsonapi/src/Requests/GetRequest.php index 19ca4b6f..98fcee97 100644 --- a/packages/jsonapi/src/Requests/GetRequest.php +++ b/packages/jsonapi/src/Requests/GetRequest.php @@ -7,16 +7,12 @@ use EDT\JsonApi\Event\AfterGetEvent; use EDT\JsonApi\Event\BeforeGetEvent; use EDT\JsonApi\ResourceTypes\GetableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use Exception; use League\Fractal\Resource\Item; use Psr\EventDispatcher\EventDispatcherInterface; /** * This request fetches a single resource by its `id` property value. - * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface */ class GetRequest { @@ -25,7 +21,7 @@ public function __construct( ) {} /** - * @param GetableTypeInterface $type + * @param GetableTypeInterface $type * @param non-empty-string $resourceId the identifier of the resource to be retrieved * * @throws Exception diff --git a/packages/jsonapi/src/Requests/ListProcessor.php b/packages/jsonapi/src/Requests/ListProcessor.php index d4ed0540..00ff8d11 100644 --- a/packages/jsonapi/src/Requests/ListProcessor.php +++ b/packages/jsonapi/src/Requests/ListProcessor.php @@ -4,6 +4,7 @@ namespace EDT\JsonApi\Requests; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\OutputHandling\ResponseFactory; use EDT\JsonApi\Pagination\PagePaginationParser; use EDT\JsonApi\RequestHandling\JsonApiSortingParser; @@ -12,7 +13,7 @@ use EDT\JsonApi\Validation\SortValidator; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterValidator; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use EDT\Wrapping\Utilities\SchemaPathProcessor; use Exception; @@ -22,18 +23,14 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ class ListProcessor { use ProcessorTrait; /** - * @param DrupalFilterParser $filterTransformer - * @param JsonApiSortingParser $sortingTransformer - * @param array&PropertyReadableTypeInterface> $listableTypes + * @param DrupalFilterParser $filterTransformer + * @param JsonApiSortingParser $sortingTransformer + * @param array&PropertyReadableTypeInterface> $listableTypes * @param non-empty-string $resourceTypeAttribute */ public function __construct( @@ -59,7 +56,7 @@ public function createResponse(Request $request): JsonResponse } /** - * @param ListableTypeInterface $type + * @param ListableTypeInterface $type * * @throws Exception */ diff --git a/packages/jsonapi/src/Requests/ListProcessorConfigInterface.php b/packages/jsonapi/src/Requests/ListProcessorConfigInterface.php index eb846442..eef505fe 100644 --- a/packages/jsonapi/src/Requests/ListProcessorConfigInterface.php +++ b/packages/jsonapi/src/Requests/ListProcessorConfigInterface.php @@ -4,6 +4,7 @@ namespace EDT\JsonApi\Requests; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\OutputHandling\PropertyReadableTypeProviderInterface; use EDT\JsonApi\OutputHandling\ResponseFactory; use EDT\JsonApi\Pagination\PagePaginationParser; @@ -12,23 +13,19 @@ use EDT\JsonApi\Validation\SortValidator; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterValidator; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Wrapping\Utilities\SchemaPathProcessor; use Psr\EventDispatcher\EventDispatcherInterface; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ interface ListProcessorConfigInterface { /** - * @return DrupalFilterParser + * @return DrupalFilterParser */ public function getFilterTransformer(): DrupalFilterParser; /** - * @return JsonApiSortingParser + * @return JsonApiSortingParser */ public function getSortingTransformer(): JsonApiSortingParser; diff --git a/packages/jsonapi/src/Requests/ListRequest.php b/packages/jsonapi/src/Requests/ListRequest.php index 8699f50b..078ba948 100644 --- a/packages/jsonapi/src/Requests/ListRequest.php +++ b/packages/jsonapi/src/Requests/ListRequest.php @@ -4,6 +4,7 @@ namespace EDT\JsonApi\Requests; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\Event\AfterListEvent; use EDT\JsonApi\Event\BeforeListEvent; use EDT\JsonApi\Pagination\PagePaginationParser; @@ -15,7 +16,7 @@ use EDT\JsonApi\Validation\SortValidator; use EDT\Querying\ConditionParsers\Drupal\DrupalFilterException; use EDT\Querying\Contracts\PathException; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Querying\Utilities\Iterables; use EDT\Wrapping\Utilities\SchemaPathProcessor; use Exception; @@ -25,15 +26,11 @@ use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ class ListRequest { /** - * @param FilterParserInterface $filterParser - * @param JsonApiSortingParser $sortingParser + * @param FilterParserInterface $filterParser + * @param JsonApiSortingParser $sortingParser */ public function __construct( protected readonly FilterParserInterface $filterParser, @@ -47,7 +44,7 @@ public function __construct( ) {} /** - * @param ListableTypeInterface $type + * @param ListableTypeInterface $type * * @throws Exception */ @@ -86,7 +83,7 @@ public function listResources(ListableTypeInterface $type): Collection } /** - * @return list + * @return list * * @throws DrupalFilterException * @throws PathException @@ -105,7 +102,7 @@ protected function getConditions(ParameterBag $query): array } /** - * @return list + * @return list * * @throws PathException * @throws InvalidArgumentException diff --git a/packages/jsonapi/src/Requests/UpdateProcessor.php b/packages/jsonapi/src/Requests/UpdateProcessor.php index 99fe54ce..dbeb3a00 100644 --- a/packages/jsonapi/src/Requests/UpdateProcessor.php +++ b/packages/jsonapi/src/Requests/UpdateProcessor.php @@ -9,7 +9,6 @@ use EDT\JsonApi\RequestHandling\RequestConstraintFactory; use EDT\JsonApi\RequestHandling\RequestWithBody; use EDT\JsonApi\ResourceTypes\UpdatableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use EDT\Wrapping\PropertyBehavior\EntityVerificationTrait; use Exception; @@ -19,10 +18,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Validator\Validator\ValidatorInterface; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface, - */ class UpdateProcessor { use EmptyResponseTrait; @@ -30,7 +25,7 @@ class UpdateProcessor use EntityVerificationTrait; /** - * @param array&PropertyReadableTypeInterface> $updatableTypes + * @param array&PropertyReadableTypeInterface> $updatableTypes * @param non-empty-string $resourceTypeAttribute * @param non-empty-string $resourceIdAttribute * @param int<1, 8192> $maxBodyNestingDepth see {@link RequestWithBody::getRequestBody} @@ -58,7 +53,7 @@ public function createResponse(Request $request): Response } /** - * @param UpdatableTypeInterface $type + * @param UpdatableTypeInterface $type * @param non-empty-string $resourceId * * @throws Exception diff --git a/packages/jsonapi/src/Requests/UpdateRequest.php b/packages/jsonapi/src/Requests/UpdateRequest.php index 6fbf67a3..56c9fbda 100644 --- a/packages/jsonapi/src/Requests/UpdateRequest.php +++ b/packages/jsonapi/src/Requests/UpdateRequest.php @@ -11,7 +11,6 @@ use EDT\JsonApi\RequestHandling\RequestConstraintFactory; use EDT\JsonApi\RequestHandling\RequestWithBody; use EDT\JsonApi\ResourceTypes\UpdatableTypeInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\PropertyBehavior\EntityVerificationTrait; use Exception; @@ -20,10 +19,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Validator\Validator\ValidatorInterface; -/** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface - */ class UpdateRequest extends RequestWithBody { use EntityVerificationTrait; @@ -47,7 +42,7 @@ public function __construct( } /** - * @param UpdatableTypeInterface $type + * @param UpdatableTypeInterface $type * @param non-empty-string $resourceId the identifier of the resource to be updated, must match the corresponding `id` field in the request body * * @throws Exception diff --git a/packages/jsonapi/src/ResourceConfig/Builder/AbstractResourceConfigBuilder.php b/packages/jsonapi/src/ResourceConfig/Builder/AbstractResourceConfigBuilder.php index 52b23409..034ba276 100644 --- a/packages/jsonapi/src/ResourceConfig/Builder/AbstractResourceConfigBuilder.php +++ b/packages/jsonapi/src/ResourceConfig/Builder/AbstractResourceConfigBuilder.php @@ -18,39 +18,33 @@ use EDT\JsonApi\PropertyConfig\ToOneRelationshipConfigInterface; use EDT\JsonApi\ResourceConfig\ResourceConfig; use EDT\JsonApi\ResourceConfig\ResourceConfigInterface; -use EDT\Querying\Contracts\PathsBasedInterface; -use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; -use EDT\Wrapping\PropertyBehavior\PropertySetBehaviorInterface; -use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; use function array_key_exists; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends BaseSchemaBuilder + * @template-extends BaseSchemaBuilder */ abstract class AbstractResourceConfigBuilder extends BaseSchemaBuilder { /** - * @var array> + * @var array> */ private array $attributes = []; /** - * @var array> + * @var array> */ private array $toOneRelationships = []; /** - * @var array> + * @var array> */ private array $toManyRelationships = []; /** * @param class-string $entityClass - * @param IdentifierConfigBuilder $identifier + * @param IdentifierConfigBuilder $identifier */ public function __construct( protected readonly string $entityClass, @@ -58,7 +52,7 @@ public function __construct( ) {} /** - * @return IdentifierConfigBuilderInterface + * @return IdentifierConfigBuilderInterface */ public function getIdentifierConfigBuilder(): IdentifierConfigBuilderInterface { @@ -147,7 +141,7 @@ protected function getBuiltIdentifierConfig(): IdentifierConfigInterface } /** - * @return array> + * @return array> */ protected function getBuiltAttributeConfigs(): array { @@ -158,7 +152,7 @@ protected function getBuiltAttributeConfigs(): array } /** - * @return array> + * @return array> */ protected function getBuiltToOneRelationshipConfigs(): array { @@ -169,7 +163,7 @@ protected function getBuiltToOneRelationshipConfigs(): array } /** - * @return array> + * @return array> */ protected function getBuiltToManyRelationshipConfigs(): array { diff --git a/packages/jsonapi/src/ResourceConfig/Builder/BaseSchemaBuilder.php b/packages/jsonapi/src/ResourceConfig/Builder/BaseSchemaBuilder.php index 2b6707ad..f474c9fe 100644 --- a/packages/jsonapi/src/ResourceConfig/Builder/BaseSchemaBuilder.php +++ b/packages/jsonapi/src/ResourceConfig/Builder/BaseSchemaBuilder.php @@ -4,17 +4,14 @@ namespace EDT\JsonApi\ResourceConfig\Builder; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; use EDT\Wrapping\PropertyBehavior\PropertySetBehaviorInterface; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-implements ResourceConfigBuilderInterface + * @template-implements ResourceConfigBuilderInterface */ abstract class BaseSchemaBuilder implements ResourceConfigBuilderInterface { @@ -29,7 +26,7 @@ abstract class BaseSchemaBuilder implements ResourceConfigBuilderInterface protected array $generalPostConstructorBehavior = []; /** - * @var list> + * @var list> */ protected array $generalUpdateBehaviors = []; diff --git a/packages/jsonapi/src/ResourceConfig/Builder/MagicResourceConfigBuilder.php b/packages/jsonapi/src/ResourceConfig/Builder/MagicResourceConfigBuilder.php index 6b125eb2..180f518d 100644 --- a/packages/jsonapi/src/ResourceConfig/Builder/MagicResourceConfigBuilder.php +++ b/packages/jsonapi/src/ResourceConfig/Builder/MagicResourceConfigBuilder.php @@ -13,7 +13,6 @@ use EDT\PathBuilding\DocblockPropertyByTraitEvaluator; use EDT\PathBuilding\PropertyEvaluatorPool; use EDT\PathBuilding\PropertyTag; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ContentField; use InvalidArgumentException; use Webmozart\Assert\Assert; @@ -30,21 +29,19 @@ * It expects subclasses to define attributes and relationships as `property-read` docblock tags. * * ``` - * property-read AttributeConfigBuilderInterface $title - * property-read ToOneRelationshipConfigBuilderInterface $publisher - * property-read ToManyRelationshipConfigBuilderInterface $authors + * property-read AttributeConfigBuilderInterface $title + * property-read ToOneRelationshipConfigBuilderInterface $publisher + * property-read ToManyRelationshipConfigBuilderInterface $authors * ``` * * When a property is accessed the magic `__get` method will be used to return the correct property config builder * instance for the accessed property name. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @property-read IdentifierConfigBuilderInterface $id the property uniquely identifying instances of this type + * @property-read IdentifierConfigBuilderInterface $id the property uniquely identifying instances of this type * - * @template-extends AbstractResourceConfigBuilder + * @template-extends AbstractResourceConfigBuilder */ abstract class MagicResourceConfigBuilder extends AbstractResourceConfigBuilder { @@ -57,7 +54,6 @@ abstract class MagicResourceConfigBuilder extends AbstractResourceConfigBuilder /** * @param class-string $entityClass - * @param PropertyBuilderFactory $propertyBuilderFactory */ public function __construct( string $entityClass, @@ -114,7 +110,7 @@ protected function getDocblockTraitEvaluator(): DocblockPropertyByTraitEvaluator /** * Multiple accesses will return the originally initialized instance. * - * @return IdentifierConfigBuilderInterface|AttributeConfigBuilderInterface|ToOneRelationshipConfigBuilderInterface|ToManyRelationshipConfigBuilderInterface + * @return IdentifierConfigBuilderInterface|AttributeConfigBuilderInterface|ToOneRelationshipConfigBuilderInterface|ToManyRelationshipConfigBuilderInterface */ public function __get(string $name): IdentifierConfigBuilderInterface|AttributeConfigBuilderInterface|ToOneRelationshipConfigBuilderInterface|ToManyRelationshipConfigBuilderInterface { diff --git a/packages/jsonapi/src/ResourceConfig/Builder/ResourceConfigBuilderInterface.php b/packages/jsonapi/src/ResourceConfig/Builder/ResourceConfigBuilderInterface.php index 78d04576..ef8e1716 100644 --- a/packages/jsonapi/src/ResourceConfig/Builder/ResourceConfigBuilderInterface.php +++ b/packages/jsonapi/src/ResourceConfig/Builder/ResourceConfigBuilderInterface.php @@ -13,64 +13,61 @@ use EDT\JsonApi\PropertyConfig\Builder\ToOneRelationshipConfigBuilder; use EDT\JsonApi\PropertyConfig\Builder\ToOneRelationshipConfigBuilderInterface; use EDT\JsonApi\ResourceConfig\ResourceConfigInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; use EDT\Wrapping\PropertyBehavior\PropertySetBehaviorInterface; use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ interface ResourceConfigBuilderInterface { /** - * @return IdentifierConfigBuilderInterface|null + * @return IdentifierConfigBuilderInterface|null */ public function getIdentifierConfigBuilder(): ?IdentifierConfigBuilderInterface; /** - * @param IdentifierConfigBuilder $builder + * @param IdentifierConfigBuilder $builder */ public function setIdentifierConfigBuilder(IdentifierConfigBuilder $builder): void; /** * @param non-empty-string $propertyName * - * @return AttributeConfigBuilderInterface|null + * @return AttributeConfigBuilderInterface|null */ public function getAttributeConfigBuilder(string $propertyName): ?AttributeConfigBuilderInterface; /** * @param non-empty-string $propertyName - * @param AttributeConfigBuilder $builder + * @param AttributeConfigBuilder $builder */ public function setAttributeConfigBuilder(string $propertyName, AttributeConfigBuilder $builder): void; /** * @param non-empty-string $propertyName * - * @return ToOneRelationshipConfigBuilderInterface|null + * @return ToOneRelationshipConfigBuilderInterface|null */ public function getToOneRelationshipConfigBuilder(string $propertyName): ?ToOneRelationshipConfigBuilderInterface; /** * @param non-empty-string $propertyName - * @param ToOneRelationshipConfigBuilder $builder + * @param ToOneRelationshipConfigBuilder $builder */ public function setToOneRelationshipConfigBuilder(string $propertyName, ToOneRelationshipConfigBuilder $builder): void; /** * @param non-empty-string $propertyName * - * @return ToManyRelationshipConfigBuilderInterface|null + * @return ToManyRelationshipConfigBuilderInterface|null */ public function getToManyRelationshipConfigBuilder(string $propertyName): ?ToManyRelationshipConfigBuilderInterface; /** * @param non-empty-string $propertyName - * @param ToManyRelationshipConfigBuilder $builder + * @param ToManyRelationshipConfigBuilder $builder */ public function setToManyRelationshipConfigBuilder(string $propertyName, ToManyRelationshipConfigBuilder $builder): void; @@ -96,7 +93,7 @@ public function addPostConstructorBehavior(PropertySetBehaviorInterface $behavio public function addCreationBehavior(PropertySetBehaviorInterface $behavior): self; /** - * @param PropertyUpdatabilityInterface $updateBehavior + * @param PropertyUpdatabilityInterface $updateBehavior * * @return $this */ @@ -113,7 +110,7 @@ public function removeAllCreationBehaviors(): self; public function removeAllUpdateBehaviors(): self; /** - * @return ResourceConfigInterface + * @return ResourceConfigInterface */ public function build(): ResourceConfigInterface; } diff --git a/packages/jsonapi/src/ResourceConfig/Builder/TypeConfig.php b/packages/jsonapi/src/ResourceConfig/Builder/TypeConfig.php index 24ac0458..97c4fce5 100644 --- a/packages/jsonapi/src/ResourceConfig/Builder/TypeConfig.php +++ b/packages/jsonapi/src/ResourceConfig/Builder/TypeConfig.php @@ -4,12 +4,12 @@ namespace EDT\JsonApi\ResourceConfig\Builder; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\InputHandling\RepositoryInterface; use EDT\JsonApi\ResourceTypes\PassThroughType; -use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; use EDT\JsonApi\Utilities\PropertyBuilderFactory; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyPathInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\Contracts\ResourceTypeProviderInterface; use EDT\Wrapping\Utilities\SchemaPathProcessor; @@ -19,22 +19,20 @@ use function is_array; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends MagicResourceConfigBuilder - * @template-implements ResourceTypeProviderInterface + * @template-extends MagicResourceConfigBuilder + * @template-implements ResourceTypeProviderInterface */ class TypeConfig extends MagicResourceConfigBuilder implements ResourceTypeProviderInterface { /** - * @var null|PassThroughType + * @var null|PassThroughType */ protected ?PassThroughType $correspondingType = null; /** - * @var list + * @var list */ protected array $accessConditions = []; @@ -44,7 +42,7 @@ class TypeConfig extends MagicResourceConfigBuilder implements ResourceTypeProvi protected ?string $typeName = null; /** - * @var list + * @var list */ protected array $defaultSortMethods = []; @@ -55,8 +53,7 @@ class TypeConfig extends MagicResourceConfigBuilder implements ResourceTypeProvi /** * @param class-string $entityClass - * @param PropertyBuilderFactory $propertyBuilderFactory - * @param RepositoryInterface $repository + * @param RepositoryInterface $repository */ public function __construct( string $entityClass, @@ -69,7 +66,7 @@ public function __construct( } /** - * @param list $conditions + * @param list $conditions */ public function setAccessConditions(array $conditions): void { @@ -85,7 +82,7 @@ public function setTypeName(string $name): void } /** - * @param list $sortMethods + * @param list $sortMethods */ public function setDefaultSortMethods(array $sortMethods): void { @@ -121,7 +118,7 @@ protected function getTypeName(): string * Later changes to this config builder or its properties may or may not be reflected in previously returned config * instances. * - * @return PassThroughType + * @return PassThroughType */ public function getType(): PassThroughType { diff --git a/packages/jsonapi/src/ResourceConfig/Builder/UnifiedResourceConfigBuilder.php b/packages/jsonapi/src/ResourceConfig/Builder/UnifiedResourceConfigBuilder.php index ccaa5f9d..0f0a8d8a 100644 --- a/packages/jsonapi/src/ResourceConfig/Builder/UnifiedResourceConfigBuilder.php +++ b/packages/jsonapi/src/ResourceConfig/Builder/UnifiedResourceConfigBuilder.php @@ -17,26 +17,20 @@ use EDT\JsonApi\PropertyConfig\ToOneRelationshipConfigInterface; use EDT\JsonApi\ResourceConfig\ResourceConfig; use EDT\JsonApi\ResourceConfig\ResourceConfigInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\ContentField; -use EDT\Wrapping\PropertyBehavior\ConstructorBehaviorInterface; -use EDT\Wrapping\PropertyBehavior\PropertySetBehaviorInterface; -use EDT\Wrapping\PropertyBehavior\PropertyUpdatabilityInterface; use Webmozart\Assert\Assert; use function array_key_exists; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends BaseSchemaBuilder + * @template-extends BaseSchemaBuilder */ class UnifiedResourceConfigBuilder extends BaseSchemaBuilder { /** * @param class-string $entityClass - * @param array|AttributeConfigBuilder|ToOneRelationshipConfigBuilder|ToManyRelationshipConfigBuilder> $properties + * @param array|AttributeConfigBuilder|ToOneRelationshipConfigBuilder|ToManyRelationshipConfigBuilder> $properties */ public function __construct( protected readonly string $entityClass, diff --git a/packages/jsonapi/src/ResourceConfig/ResourceConfig.php b/packages/jsonapi/src/ResourceConfig/ResourceConfig.php index c513da27..8b6dd083 100644 --- a/packages/jsonapi/src/ResourceConfig/ResourceConfig.php +++ b/packages/jsonapi/src/ResourceConfig/ResourceConfig.php @@ -10,7 +10,6 @@ use EDT\JsonApi\PropertyConfig\RelationshipConfigInterface; use EDT\JsonApi\PropertyConfig\ToManyRelationshipConfigInterface; use EDT\JsonApi\PropertyConfig\ToOneRelationshipConfigInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; use EDT\Querying\Utilities\Iterables; use EDT\Wrapping\Contracts\ContentField; @@ -26,28 +25,26 @@ use Webmozart\Assert\Assert; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-implements ResourceConfigInterface + * @template-implements ResourceConfigInterface */ class ResourceConfig implements ResourceConfigInterface { /** - * @var array|RelationshipConfigInterface> + * @var array|RelationshipConfigInterface> */ protected readonly array $propertyConfigs; /** * @param class-string $entityClass * @param IdentifierConfigInterface $identifierConfig - * @param array> $attributeConfigs - * @param array> $toOneRelationshipConfigs - * @param array> $toManyRelationshipConfigs + * @param array> $attributeConfigs + * @param array> $toOneRelationshipConfigs + * @param array> $toManyRelationshipConfigs * @param list $generalConstructorBehaviors * @param list> $generalPostConstructorBehaviors - * @param list> $generalUpdateBehaviors + * @param list> $generalUpdateBehaviors */ public function __construct( protected readonly string $entityClass, diff --git a/packages/jsonapi/src/ResourceConfig/ResourceConfigInterface.php b/packages/jsonapi/src/ResourceConfig/ResourceConfigInterface.php index 9b7611f3..a996336e 100644 --- a/packages/jsonapi/src/ResourceConfig/ResourceConfigInterface.php +++ b/packages/jsonapi/src/ResourceConfig/ResourceConfigInterface.php @@ -4,7 +4,6 @@ namespace EDT\JsonApi\ResourceConfig; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\FilteringTypeInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use EDT\Wrapping\Contracts\Types\PropertyUpdatableTypeInterface; @@ -12,13 +11,10 @@ use EDT\Wrapping\ResourceBehavior\ResourceInstantiability; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends PropertyUpdatableTypeInterface - * @template-extends PropertyReadableTypeInterface - * @template-extends SortingTypeInterface + * @template-extends PropertyUpdatableTypeInterface + * @template-extends PropertyReadableTypeInterface */ interface ResourceConfigInterface extends PropertyUpdatableTypeInterface, FilteringTypeInterface, SortingTypeInterface, PropertyReadableTypeInterface { diff --git a/packages/jsonapi/src/ResourceTypes/AbstractResourceType.php b/packages/jsonapi/src/ResourceTypes/AbstractResourceType.php index 0cad9c89..86c6bff5 100644 --- a/packages/jsonapi/src/ResourceTypes/AbstractResourceType.php +++ b/packages/jsonapi/src/ResourceTypes/AbstractResourceType.php @@ -4,13 +4,14 @@ namespace EDT\JsonApi\ResourceTypes; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\InputHandling\RepositoryInterface; use EDT\JsonApi\RequestHandling\ExpectedPropertyCollectionInterface; use EDT\JsonApi\RequestHandling\ModifiedEntity; use EDT\Querying\Contracts\EntityBasedInterface; use EDT\Querying\Contracts\PathException; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Pagination\PagePagination; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Wrapping\Contracts\ContentField; use EDT\Wrapping\Contracts\Types\FetchableTypeInterface; use EDT\Wrapping\CreationDataInterface; @@ -20,19 +21,17 @@ use Pagerfanta\Pagerfanta; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-implements ResourceTypeInterface - * @template-implements FetchableTypeInterface - * @template-implements GetableTypeInterface - * @template-implements CreatableTypeInterface + * @template-implements ResourceTypeInterface + * @template-implements FetchableTypeInterface + * @template-implements GetableTypeInterface + * @template-implements CreatableTypeInterface */ abstract class AbstractResourceType implements ResourceTypeInterface, FetchableTypeInterface, GetableTypeInterface, DeletableTypeInterface, CreatableTypeInterface { /** - * @return RepositoryInterface + * @return RepositoryInterface */ abstract protected function getRepository(): RepositoryInterface; @@ -102,7 +101,7 @@ public function createEntity(CreationDataInterface $entityData): ModifiedEntity * For a list query on a `CatType` the condition returned by this method must define * limits to only get `Animal` instances that are a `Cat`. * - * @return list + * @return list */ abstract protected function getAccessConditions(): array; @@ -116,7 +115,7 @@ abstract protected function getSchemaPathProcessor(): SchemaPathProcessor; * * Return an empty array to not define any default sorting. * - * @return list + * @return list */ abstract protected function getDefaultSortMethods(): array; @@ -137,8 +136,8 @@ abstract protected function getInstantiability(): ResourceInstantiability; * be passed into this method, as their paths are expected to already denote actual properties in a * backing entity. * - * @param list $conditions - * @param list $sortMethods + * @param list $conditions + * @param list $sortMethods * * @throws PathException */ diff --git a/packages/jsonapi/src/ResourceTypes/CreatableTypeInterface.php b/packages/jsonapi/src/ResourceTypes/CreatableTypeInterface.php index eb9d1ce2..6dfc494f 100644 --- a/packages/jsonapi/src/ResourceTypes/CreatableTypeInterface.php +++ b/packages/jsonapi/src/ResourceTypes/CreatableTypeInterface.php @@ -7,13 +7,10 @@ use EDT\JsonApi\RequestHandling\ExpectedPropertyCollectionInterface; use EDT\JsonApi\RequestHandling\ModifiedEntity; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\NamedTypeInterface; use EDT\Wrapping\CreationDataInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ interface CreatableTypeInterface extends NamedTypeInterface, ReadableTypeInterface diff --git a/packages/jsonapi/src/ResourceTypes/GetableTypeInterface.php b/packages/jsonapi/src/ResourceTypes/GetableTypeInterface.php index 3ce57d8c..7a8038d9 100644 --- a/packages/jsonapi/src/ResourceTypes/GetableTypeInterface.php +++ b/packages/jsonapi/src/ResourceTypes/GetableTypeInterface.php @@ -4,13 +4,10 @@ namespace EDT\JsonApi\ResourceTypes; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\NamedTypeInterface; use Exception; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ interface GetableTypeInterface extends ReadableTypeInterface, NamedTypeInterface diff --git a/packages/jsonapi/src/ResourceTypes/ListableTypeInterface.php b/packages/jsonapi/src/ResourceTypes/ListableTypeInterface.php index 63cff320..4a383e4b 100644 --- a/packages/jsonapi/src/ResourceTypes/ListableTypeInterface.php +++ b/packages/jsonapi/src/ResourceTypes/ListableTypeInterface.php @@ -5,17 +5,14 @@ namespace EDT\JsonApi\ResourceTypes; use EDT\Querying\Contracts\EntityBasedInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\FetchableTypeInterface; use EDT\Wrapping\Contracts\Types\NamedTypeInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * * @template-extends EntityBasedInterface - * @template-extends FetchableTypeInterface + * @template-extends FetchableTypeInterface */ interface ListableTypeInterface extends EntityBasedInterface, NamedTypeInterface, ReadableTypeInterface, FetchableTypeInterface { diff --git a/packages/jsonapi/src/ResourceTypes/PassThroughType.php b/packages/jsonapi/src/ResourceTypes/PassThroughType.php index db138e41..d62d3606 100644 --- a/packages/jsonapi/src/ResourceTypes/PassThroughType.php +++ b/packages/jsonapi/src/ResourceTypes/PassThroughType.php @@ -4,11 +4,12 @@ namespace EDT\JsonApi\ResourceTypes; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\JsonApi\InputHandling\RepositoryInterface; use EDT\JsonApi\OutputHandling\DynamicTransformer; use EDT\JsonApi\RequestHandling\MessageFormatter; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\PropertyPaths\PropertyLinkInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use EDT\Wrapping\ResourceBehavior\ResourceInstantiability; use EDT\Wrapping\ResourceBehavior\ResourceReadability; use EDT\Wrapping\ResourceBehavior\ResourceUpdatability; @@ -17,29 +18,27 @@ use Psr\Log\LoggerInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends AbstractResourceType - * @template-implements UpdatableTypeInterface - * @template-implements ListableTypeInterface + * @template-extends AbstractResourceType + * @template-implements UpdatableTypeInterface + * @template-implements ListableTypeInterface */ class PassThroughType extends AbstractResourceType implements UpdatableTypeInterface, ListableTypeInterface { protected readonly MessageFormatter $messageFormatter; /** - * @param RepositoryInterface $repository - * @param list $accessConditions - * @param list $defaultSortMethods + * @param RepositoryInterface $repository + * @param list $accessConditions + * @param list $defaultSortMethods * @param ResourceInstantiability $instantiability * @param non-empty-list $identifierPropertyPath * @param class-string $entityClass * @param array $filteringProperties * @param non-empty-string $typeName - * @param ResourceReadability $readability - * @param ResourceUpdatability $updatability + * @param ResourceReadability $readability + * @param ResourceUpdatability $updatability * @param array $sortingProperties */ public function __construct( diff --git a/packages/jsonapi/src/ResourceTypes/ResourceTypeInterface.php b/packages/jsonapi/src/ResourceTypes/ResourceTypeInterface.php index 537337e5..5df4a29f 100644 --- a/packages/jsonapi/src/ResourceTypes/ResourceTypeInterface.php +++ b/packages/jsonapi/src/ResourceTypes/ResourceTypeInterface.php @@ -4,18 +4,14 @@ namespace EDT\JsonApi\ResourceTypes; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\FilteringTypeInterface; use EDT\Wrapping\Contracts\Types\TransferableTypeInterface; use EDT\Wrapping\Contracts\Types\SortingTypeInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends TransferableTypeInterface - * @template-extends SortingTypeInterface + * @template-extends TransferableTypeInterface */ interface ResourceTypeInterface extends TransferableTypeInterface, diff --git a/packages/jsonapi/src/ResourceTypes/UpdatableTypeInterface.php b/packages/jsonapi/src/ResourceTypes/UpdatableTypeInterface.php index 1a9df0ba..9473fefb 100644 --- a/packages/jsonapi/src/ResourceTypes/UpdatableTypeInterface.php +++ b/packages/jsonapi/src/ResourceTypes/UpdatableTypeInterface.php @@ -4,16 +4,13 @@ namespace EDT\JsonApi\ResourceTypes; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\NamedTypeInterface; use EDT\Wrapping\Contracts\Types\UpdatableInterface; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object * - * @template-extends UpdatableInterface + * @template-extends UpdatableInterface */ interface UpdatableTypeInterface extends NamedTypeInterface, UpdatableInterface, ReadableTypeInterface { diff --git a/packages/jsonapi/src/Utilities/NameBasedTypeProvider.php b/packages/jsonapi/src/Utilities/NameBasedTypeProvider.php index 41ace1c0..75c8c088 100644 --- a/packages/jsonapi/src/Utilities/NameBasedTypeProvider.php +++ b/packages/jsonapi/src/Utilities/NameBasedTypeProvider.php @@ -5,14 +5,13 @@ namespace EDT\JsonApi\Utilities; use EDT\JsonApi\OutputHandling\PropertyReadableTypeProviderInterface; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use Webmozart\Assert\Assert; class NameBasedTypeProvider implements PropertyReadableTypeProviderInterface { /** - * @var array> + * @var array> */ protected array $types = []; diff --git a/packages/jsonapi/src/Utilities/PropertyBuilderFactory.php b/packages/jsonapi/src/Utilities/PropertyBuilderFactory.php index 7405f672..d154c52a 100644 --- a/packages/jsonapi/src/Utilities/PropertyBuilderFactory.php +++ b/packages/jsonapi/src/Utilities/PropertyBuilderFactory.php @@ -12,7 +12,6 @@ use EDT\JsonApi\ResourceTypes\ResourceTypeInterface; use EDT\Querying\Contracts\EntityBasedInterface; use EDT\Querying\Contracts\PathException; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyAccessorInterface; use EDT\Querying\Contracts\PropertyPathInterface; use Webmozart\Assert\Assert; @@ -21,9 +20,6 @@ /** * Allows to create instances to configure properties (id/attribute/relationship). Each instance created can be used to * configure the single property it was created for. - * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface */ class PropertyBuilderFactory { @@ -55,7 +51,7 @@ public function __construct( * @param class-string $entityClass * @param PropertyPathInterface|non-empty-string $name * - * @return AttributeConfigBuilder + * @return AttributeConfigBuilder * * @throws PathException */ @@ -86,9 +82,9 @@ public function createAttribute(string $entityClass, PropertyPathInterface|strin * @template TRelationship of object * * @param class-string $entityClass - * @param PropertyPathInterface&EntityBasedInterface&ResourceTypeInterface $nameAndType + * @param PropertyPathInterface&EntityBasedInterface&ResourceTypeInterface $nameAndType * - * @return ToOneRelationshipConfigBuilder + * @return ToOneRelationshipConfigBuilder * * @throws PathException */ @@ -115,7 +111,7 @@ public function createToOne( * @param class-string $relationshipClass * @param PropertyPathInterface|non-empty-string $name * - * @return ToOneRelationshipConfigBuilder + * @return ToOneRelationshipConfigBuilder * * @throws PathException */ @@ -149,9 +145,9 @@ public function createToOneWithType( * @template TRelationship of object * * @param class-string $entityClass - * @param PropertyPathInterface&EntityBasedInterface&ResourceTypeInterface $nameAndType + * @param PropertyPathInterface&EntityBasedInterface&ResourceTypeInterface $nameAndType * - * @return ToManyRelationshipConfigBuilder + * @return ToManyRelationshipConfigBuilder * * @throws PathException */ @@ -178,7 +174,7 @@ public function createToMany( * @param class-string $relationshipClass * @param PropertyPathInterface|non-empty-string $nameOrPath * - * @return ToManyRelationshipConfigBuilder + * @return ToManyRelationshipConfigBuilder * * @throws PathException */ @@ -230,7 +226,7 @@ protected function getSingleName(PropertyPathInterface|string $nameOrPath) * * @param class-string $entityClass * - * @return IdentifierConfigBuilder + * @return IdentifierConfigBuilder */ public function createIdentifier(string $entityClass): IdentifierConfigBuilder { diff --git a/packages/jsonapi/src/Validation/FieldsValidator.php b/packages/jsonapi/src/Validation/FieldsValidator.php index 36e915f5..fc904ac6 100644 --- a/packages/jsonapi/src/Validation/FieldsValidator.php +++ b/packages/jsonapi/src/Validation/FieldsValidator.php @@ -4,7 +4,6 @@ namespace EDT\JsonApi\Validation; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints as Assert; @@ -100,7 +99,7 @@ public function validateFormat(mixed $fieldValue): array * I.e. after calling {@link validateFormat} you would loop through the result and retrieve the corresponding type * for each array key. The type instance and the array's value are then passed into this method. * - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * * @return list All property names in that the given string, that are readable in the given type. * This includes malformed property names like empty strings. diff --git a/packages/jsonapi/src/Validation/IncludeValidator.php b/packages/jsonapi/src/Validation/IncludeValidator.php index 728e4c3d..65137fde 100644 --- a/packages/jsonapi/src/Validation/IncludeValidator.php +++ b/packages/jsonapi/src/Validation/IncludeValidator.php @@ -4,7 +4,6 @@ namespace EDT\JsonApi\Validation; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Wrapping\Contracts\Types\PropertyReadableTypeInterface; use EDT\Wrapping\Utilities\SchemaPathProcessor; use Exception; @@ -28,7 +27,7 @@ public function __construct( * The required include format can be ensured by calling {@link assertIncludeFormat} first. * * @param list> $includes a list of paths - * @param PropertyReadableTypeInterface $type + * @param PropertyReadableTypeInterface $type * * @throws Exception if any path segment in the given paths is not set as readable in the corresponding type; thrown at the first problem */ diff --git a/packages/jsonapi/tests/OutputTransformation/DynamicTransformerTest.php b/packages/jsonapi/tests/OutputTransformation/DynamicTransformerTest.php index b81c8668..8f6a3279 100644 --- a/packages/jsonapi/tests/OutputTransformation/DynamicTransformerTest.php +++ b/packages/jsonapi/tests/OutputTransformation/DynamicTransformerTest.php @@ -4,6 +4,7 @@ namespace Tests\OutputTransformation; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\JsonApi\OutputHandling\DynamicTransformer; use EDT\JsonApi\RequestHandling\MessageFormatter; @@ -27,7 +28,7 @@ class DynamicTransformerTest extends ModelBasedTest { private Manager $fractal; - private PhpConditionFactory $conditionFactory; + private ConditionFactory $conditionFactory; private PropertyBuilderFactory $propertyBuilderFactory; private MessageFormatter $messageFormatter; @@ -82,7 +83,7 @@ protected function setUp(): void $this->propertyAccessor = new ReflectionPropertyAccessor(); $this->messageFormatter = new MessageFormatter(); - $conditionFactory = new PhpConditionFactory(); + $conditionFactory = new ConditionFactory(); $this->conditionFactory = $conditionFactory; $lazyTypeProvider = new LazyTypeProvider(); $this->typeResolver = new AttributeTypeResolver(); diff --git a/packages/jsonapi/tests/Validation/FieldsValidatorTest.php b/packages/jsonapi/tests/Validation/FieldsValidatorTest.php index 02ceddfd..fd34cb27 100644 --- a/packages/jsonapi/tests/Validation/FieldsValidatorTest.php +++ b/packages/jsonapi/tests/Validation/FieldsValidatorTest.php @@ -4,6 +4,7 @@ namespace Tests\Validation; +use EDT\ConditionFactory\ConditionFactory; use EDT\JsonApi\ApiDocumentation\AttributeTypeResolver; use EDT\JsonApi\Validation\FieldsException; use EDT\JsonApi\Validation\FieldsValidator; @@ -26,7 +27,7 @@ class FieldsValidatorTest extends TestCase protected function setUp(): void { parent::setUp(); - $conditionFactory = new PhpConditionFactory(); + $conditionFactory = new ConditionFactory(); $lazyTypeProvider = new LazyTypeProvider(); $propertyAccessor = new ReflectionPropertyAccessor(); $attributeTypeResover = new AttributeTypeResolver(); diff --git a/packages/jsonapi/tests/data/ApiTypes/AuthorType.php b/packages/jsonapi/tests/data/ApiTypes/AuthorType.php index a0240916..82cb6f92 100644 --- a/packages/jsonapi/tests/data/ApiTypes/AuthorType.php +++ b/packages/jsonapi/tests/data/ApiTypes/AuthorType.php @@ -63,7 +63,6 @@ public function getReadability(): ResourceReadability $this->getEntityClass(), ['id'], $this->propertyAccessor, - $this->typeResolver ) ); } diff --git a/packages/queries/src/ConditionFactories/PhpConditionFactory.php b/packages/queries/src/ConditionFactories/PhpConditionFactory.php index b65f245a..3ace48b0 100644 --- a/packages/queries/src/ConditionFactories/PhpConditionFactory.php +++ b/packages/queries/src/ConditionFactories/PhpConditionFactory.php @@ -4,8 +4,8 @@ namespace EDT\Querying\ConditionFactories; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; -use EDT\ConditionFactory\PathsBasedConditionGroupFactoryInterface; +use EDT\ConditionFactory\ConditionFactoryInterface; +use EDT\ConditionFactory\ConditionGroupFactoryInterface; use EDT\Querying\Contracts\FunctionInterface; use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyPathAccessInterface; @@ -31,10 +31,10 @@ use function count; /** - * @template-implements PathsBasedConditionFactoryInterface> - * @template-implements PathsBasedConditionGroupFactoryInterface> + * @template-implements ConditionFactoryInterface> + * @template-implements ConditionGroupFactoryInterface> */ -class PhpConditionFactory implements PathsBasedConditionFactoryInterface, PathsBasedConditionGroupFactoryInterface +class PhpConditionFactory implements ConditionFactoryInterface, ConditionGroupFactoryInterface { public function true(): PathsBasedInterface { diff --git a/packages/queries/src/ConditionFactory/AbstractDrupalFilter.php b/packages/queries/src/ConditionFactory/AbstractDrupalFilter.php index dd99828a..0b43a9a7 100644 --- a/packages/queries/src/ConditionFactory/AbstractDrupalFilter.php +++ b/packages/queries/src/ConditionFactory/AbstractDrupalFilter.php @@ -4,41 +4,9 @@ namespace EDT\ConditionFactory; -use EDT\Querying\Contracts\PropertyPathInterface; -use function is_array; -use function is_string; +use EDT\Querying\Utilities\PathConverterTrait; -abstract class AbstractDrupalFilter +abstract class AbstractDrupalFilter implements DrupalFilterInterface { - /** - * Returns the content of this group as a flat list in the Drupal filter format. - * - * @param non-empty-string $name - * - * @return array>> - */ - abstract public function toDrupalArray(string $name, string $memberOf = ''): array; - - /** - * @param null|callable(array $content): array $contentRewriter - */ - abstract public function deepCopy(callable $contentRewriter = null): AbstractDrupalFilter; - - /** - * @param non-empty-string|non-empty-list|PropertyPathInterface $path - * - * @return non-empty-string - */ - protected static function pathToString(string|array|PropertyPathInterface $path): string - { - if (is_string($path)) { - return $path; - } - - if (is_array($path)) { - return implode('.', $path); - } - - return $path->getAsNamesInDotNotation(); - } + use PathConverterTrait; } diff --git a/packages/queries/src/ConditionFactory/ConditionFactory.php b/packages/queries/src/ConditionFactory/ConditionFactory.php new file mode 100644 index 00000000..ee8793fb --- /dev/null +++ b/packages/queries/src/ConditionFactory/ConditionFactory.php @@ -0,0 +1,188 @@ + + * @template-implements ConditionGroupFactoryInterface + */ +class ConditionFactory implements ConditionGroupFactoryInterface, ConditionFactoryInterface +{ + public function propertyIsNull(array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithoutValue($properties, IsNull::OPERATOR); + } + + public function propertyHasAnyOfValues(array $values, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, In::OPERATOR, $values); + } + + public function propertyHasNotAnyOfValues(array $values, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, NotIn::OPERATOR, $values); + } + + public function true() + { + return new MutableDrupalCondition(DrupalFilterParser::CONDITION, [ + DrupalFilterParser::OPERATOR => AlwaysTrue::OPERATOR, + ]); + } + + public function propertyHasSize(int $size, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, Size::OPERATOR, $size); + } + + public function propertyHasNotSize(int $size, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, NotSize::OPERATOR, $size); + } + + public function false() + { + return new MutableDrupalCondition(DrupalFilterParser::CONDITION, [ + DrupalFilterParser::OPERATOR => AlwaysFalse::OPERATOR, + ]); + } + + public function propertiesEqual(array $leftProperties, array $rightProperties) + { + // TODO: support different context for right property path? + return MutableDrupalCondition::createWithValue( + $leftProperties, + PropertiesEqual::OPERATOR, + $leftProperties, + ); + } + + public function propertyHasStringContainingCaseInsensitiveValue(string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, StringContains::OPERATOR, $value); + } + + public function propertyHasValue(float|bool|int|string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, Equals::OPERATOR, $value); + } + + public function propertyBetweenValuesInclusive(float|int|string $min, float|int|string $max, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, Between::OPERATOR, [$min, $max]); + } + + public function propertyNotBetweenValuesInclusive(float|int|string $min, float|int|string $max, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, NotBetween::OPERATOR, [$min, $max]); + } + + public function propertyHasStringAsMember(string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, MemberOf::OPERATOR, $value); + } + + public function valueGreaterThan(float|int|string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, GreaterThan::OPERATOR, $value); + } + + public function valueGreaterEqualsThan(float|int|string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, GreaterEqualsThan::OPERATOR, $value); + } + + public function valueSmallerThan(float|int|string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, LesserThan::OPERATOR, $value); + } + + public function valueSmallerEqualsThan(float|int|string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, LesserEqualsThan::OPERATOR, $value); + } + + public function propertyStartsWithCaseInsensitive(string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, StartsWith::OPERATOR, $value); + } + + public function propertyEndsWithCaseInsensitive(string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, EndsWith::OPERATOR, $value); + } + + public function allValuesPresentInMemberListProperties(array $values, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, ContainsAll::OPERATOR, $values); + } + + public function propertyHasNotValue(float|bool|int|string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, NotEquals::OPERATOR, $value); + } + + public function propertyIsNotNull(array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithoutValue($properties, IsNotNull::OPERATOR); + } + + public function propertyHasNotStringAsMember(string $value, array|string|PropertyPathInterface $properties) + { + return MutableDrupalCondition::createWithValue($properties, NotMemberOf::OPERATOR, $value); + } + + public function allConditionsApply($firstCondition, ...$additionalConditions) + { + $group = MutableDrupalGroup::createAnd(); + $this->fillGroup($group, array_values([$firstCondition, ...$additionalConditions])); + + return $group; + } + + public function anyConditionApplies($firstCondition, ...$additionalConditions) + { + $group = MutableDrupalGroup::createOr(); + $this->fillGroup($group, array_values([$firstCondition, ...$additionalConditions])); + + return $group; + } + + /** + * @param non-empty-list $conditions + */ + protected function fillGroup(MutableDrupalGroup $group, array $conditions): void + { + foreach ($conditions as $condition) { + $group->addChild($condition, ''); + } + } +} diff --git a/packages/queries/src/ConditionFactory/DrupalFilterInterface.php b/packages/queries/src/ConditionFactory/DrupalFilterInterface.php new file mode 100644 index 00000000..a3be7d16 --- /dev/null +++ b/packages/queries/src/ConditionFactory/DrupalFilterInterface.php @@ -0,0 +1,24 @@ +>> + */ + public function toDrupalArray(string $name, string $memberOf = ''): array; + + /** + * @param null|callable(array $content): array $contentRewriter + */ + public function deepCopy(callable $contentRewriter = null): DrupalFilterInterface; +} diff --git a/packages/queries/src/ConditionFactory/MutableDrupalCondition.php b/packages/queries/src/ConditionFactory/MutableDrupalCondition.php index 74bb077a..08243151 100644 --- a/packages/queries/src/ConditionFactory/MutableDrupalCondition.php +++ b/packages/queries/src/ConditionFactory/MutableDrupalCondition.php @@ -6,19 +6,23 @@ use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; use EDT\Querying\Contracts\PropertyPathInterface; +use EDT\Querying\Utilities\PathConverterTrait; +use Webmozart\Assert\Assert; /** * @phpstan-import-type DrupalValue from DrupalFilterParser */ class MutableDrupalCondition extends AbstractDrupalFilter { + use PathConverterTrait; + /** * @param non-empty-string $type * @param array $content */ public function __construct( protected readonly string $type, - protected readonly array $content + protected array $content ) {} /** @@ -69,7 +73,7 @@ public function toDrupalArray(string $name, string $memberOf = ''): array ]; } - public function deepCopy(callable $contentRewriter = null): AbstractDrupalFilter + public function deepCopy(callable $contentRewriter = null): DrupalFilterInterface { $content = null === $contentRewriter ? $this->content @@ -77,4 +81,16 @@ public function deepCopy(callable $contentRewriter = null): AbstractDrupalFilter return new self($this->type, $content); } + + public function adjustPath(callable $callable): void + { + $pathString = $this->content[DrupalFilterParser::PATH] ?? null; + if (null !== $pathString) { + Assert::stringNotEmpty($pathString); + $oldPath = self::pathToArray($pathString); + Assert::allStringNotEmpty($oldPath); + $newPath = $callable($oldPath); + $this->content[DrupalFilterParser::PATH] = static::pathToString($newPath); + } + } } diff --git a/packages/queries/src/ConditionFactory/MutableDrupalGroup.php b/packages/queries/src/ConditionFactory/MutableDrupalGroup.php index a34a0c90..7c7590a2 100644 --- a/packages/queries/src/ConditionFactory/MutableDrupalGroup.php +++ b/packages/queries/src/ConditionFactory/MutableDrupalGroup.php @@ -13,7 +13,7 @@ class MutableDrupalGroup extends AbstractDrupalFilter { /** - * @var list + * @var list */ protected array $children = []; @@ -34,7 +34,7 @@ public static function createOr(): self return new self(DrupalFilterParser::OR); } - public function addChild(AbstractDrupalFilter $filter, string $namePrefix): void + public function addChild(DrupalFilterInterface $filter, string $namePrefix): void { $this->children[] = [ 'namePrefix' => $namePrefix, @@ -59,7 +59,7 @@ public function toDrupalArray(string $name, string $memberOf = ''): array return $result; } - public function deepCopy(callable $contentRewriter = null): AbstractDrupalFilter + public function deepCopy(callable $contentRewriter = null): DrupalFilterInterface { $copy = new self($this->conjunction); foreach ($this->children as ['namePrefix' => $namePrefix, 'filter' => $filter]) { @@ -98,4 +98,12 @@ protected function createName(string $identifier, ?int $index): string return null === $index ? $identifier : "$identifier-$index"; } + + public function adjustPath(callable $callable): void + { + array_map( + static fn (DrupalFilterInterface $filter) => $filter->adjustPath($callable), + array_column($this->children, 'filter') + ); + } } diff --git a/packages/queries/src/ConditionFactory/PathsBasedConditionFactoryInterface.php b/packages/queries/src/ConditionFactory/PathsBasedConditionFactoryInterface.php deleted file mode 100644 index bbb9016c..00000000 --- a/packages/queries/src/ConditionFactory/PathsBasedConditionFactoryInterface.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ -interface PathsBasedConditionFactoryInterface extends ConditionFactoryInterface -{ -} diff --git a/packages/queries/src/ConditionFactory/PathsBasedConditionGroupFactoryInterface.php b/packages/queries/src/ConditionFactory/PathsBasedConditionGroupFactoryInterface.php deleted file mode 100644 index fab3654e..00000000 --- a/packages/queries/src/ConditionFactory/PathsBasedConditionGroupFactoryInterface.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ -interface PathsBasedConditionGroupFactoryInterface extends ConditionGroupFactoryInterface -{ -} diff --git a/packages/queries/src/Conditions/AbstractCondition.php b/packages/queries/src/Conditions/AbstractCondition.php index 7ee2712b..3f9c7ef2 100644 --- a/packages/queries/src/Conditions/AbstractCondition.php +++ b/packages/queries/src/Conditions/AbstractCondition.php @@ -9,8 +9,6 @@ /** * @template TCondition of PathsBasedInterface - * - * @template-implements ConditionInterface */ abstract class AbstractCondition implements ConditionInterface { diff --git a/packages/queries/src/Conditions/ConditionInterface.php b/packages/queries/src/Conditions/ConditionInterface.php index c084a78d..9642d277 100644 --- a/packages/queries/src/Conditions/ConditionInterface.php +++ b/packages/queries/src/Conditions/ConditionInterface.php @@ -4,12 +4,8 @@ namespace EDT\Querying\Conditions; -use EDT\Querying\Contracts\PathsBasedInterface; use Symfony\Component\Validator\Constraint; -/** - * @template TCondition of PathsBasedInterface - */ interface ConditionInterface { /** diff --git a/packages/queries/src/Conditions/Equals.php b/packages/queries/src/Conditions/Equals.php index 1344208c..fd4c0891 100644 --- a/packages/queries/src/Conditions/Equals.php +++ b/packages/queries/src/Conditions/Equals.php @@ -5,7 +5,6 @@ namespace EDT\Querying\Conditions; use EDT\Querying\Contracts\PathsBasedInterface; -use InvalidArgumentException; use Webmozart\Assert\Assert; use function is_bool; use function is_float; diff --git a/packages/queries/src/Conditions/GreaterEqualsThan.php b/packages/queries/src/Conditions/GreaterEqualsThan.php index 0f935a13..78cd12e4 100644 --- a/packages/queries/src/Conditions/GreaterEqualsThan.php +++ b/packages/queries/src/Conditions/GreaterEqualsThan.php @@ -5,7 +5,6 @@ namespace EDT\Querying\Conditions; use EDT\Querying\Contracts\PathsBasedInterface; -use InvalidArgumentException; use Webmozart\Assert\Assert; use function is_float; use function is_int; diff --git a/packages/queries/src/Conditions/ValueDependentConditionInterface.php b/packages/queries/src/Conditions/ValueDependentConditionInterface.php index 988fe085..3f38b30b 100644 --- a/packages/queries/src/Conditions/ValueDependentConditionInterface.php +++ b/packages/queries/src/Conditions/ValueDependentConditionInterface.php @@ -5,12 +5,9 @@ namespace EDT\Querying\Conditions; use EDT\Querying\Contracts\PathException; -use EDT\Querying\Contracts\PathsBasedInterface; /** - * @template TCondition of PathsBasedInterface - * - * @template-extends ConditionInterface + * @template TCondition */ interface ValueDependentConditionInterface extends ConditionInterface { @@ -21,5 +18,5 @@ interface ValueDependentConditionInterface extends ConditionInterface * * @throws PathException */ - public function transform(?array $path, mixed $value): PathsBasedInterface; + public function transform(?array $path, mixed $value); } diff --git a/packages/queries/src/Conditions/ValueIndependentConditionInterface.php b/packages/queries/src/Conditions/ValueIndependentConditionInterface.php index 2747de75..00b294f8 100644 --- a/packages/queries/src/Conditions/ValueIndependentConditionInterface.php +++ b/packages/queries/src/Conditions/ValueIndependentConditionInterface.php @@ -4,12 +4,8 @@ namespace EDT\Querying\Conditions; -use EDT\Querying\Contracts\PathsBasedInterface; - /** - * @template TCondition of PathsBasedInterface - * - * @template-extends ConditionInterface + * @template TCondition */ interface ValueIndependentConditionInterface extends ConditionInterface { @@ -18,5 +14,5 @@ interface ValueIndependentConditionInterface extends ConditionInterface * * @return TCondition */ - public function transform(?array $path): PathsBasedInterface; + public function transform(?array $path); } diff --git a/packages/queries/src/Contracts/ConditionParserInterface.php b/packages/queries/src/Contracts/ConditionParserInterface.php index 5e127ad7..2f8381ed 100644 --- a/packages/queries/src/Contracts/ConditionParserInterface.php +++ b/packages/queries/src/Contracts/ConditionParserInterface.php @@ -17,7 +17,7 @@ * * @phpstan-import-type DrupalFilterCondition from DrupalFilterParser * - * @template TCondition of PathsBasedInterface + * @template TCondition */ interface ConditionParserInterface { @@ -26,5 +26,5 @@ interface ConditionParserInterface * * @return TCondition */ - public function parseCondition(array $condition): PathsBasedInterface; + public function parseCondition(array $condition); } diff --git a/packages/queries/src/Contracts/MappingEntityProvider.php b/packages/queries/src/Contracts/MappingEntityProvider.php new file mode 100644 index 00000000..21a883c7 --- /dev/null +++ b/packages/queries/src/Contracts/MappingEntityProvider.php @@ -0,0 +1,41 @@ + + */ +class MappingEntityProvider implements OffsetEntityProviderInterface +{ + /** + * @template TCondition + * @template TSorting + * + * @param ConditionConverter $conditionConverter + * @param SortMethodConverter $sortMethodConverter + * @param OffsetEntityProviderInterface $entityProvider + */ + public function __construct( + protected readonly ConditionConverter $conditionConverter, + protected readonly SortMethodConverter $sortMethodConverter, + protected readonly OffsetEntityProviderInterface $entityProvider + ) {} + + public function getEntities(array $conditions, array $sortMethods, ?OffsetPagination $pagination): array + { + $conditions = $this->conditionConverter->convertConditions($conditions); + $sortMethods = $this->sortMethodConverter->convertSortMethods($sortMethods); + + return $this->entityProvider->getEntities($conditions, $sortMethods, $pagination); + } +} diff --git a/packages/queries/src/Contracts/OffsetEntityProviderInterface.php b/packages/queries/src/Contracts/OffsetEntityProviderInterface.php index f86f4f0d..ddae7101 100644 --- a/packages/queries/src/Contracts/OffsetEntityProviderInterface.php +++ b/packages/queries/src/Contracts/OffsetEntityProviderInterface.php @@ -7,8 +7,8 @@ use EDT\Querying\Pagination\OffsetPagination; /** - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface + * @template TCondition + * @template TSorting * @template TEntity of object */ interface OffsetEntityProviderInterface @@ -18,7 +18,6 @@ interface OffsetEntityProviderInterface * * @param list $conditions * @param list $sortMethods - * @param OffsetPagination|null $pagination * * @return list * diff --git a/packages/queries/src/Contracts/PathAdjustableInterface.php b/packages/queries/src/Contracts/PathAdjustableInterface.php new file mode 100644 index 00000000..1b19142c --- /dev/null +++ b/packages/queries/src/Contracts/PathAdjustableInterface.php @@ -0,0 +1,15 @@ +): non-empty-list $callable + */ + public function adjustPath(callable $callable): void; +} diff --git a/packages/queries/src/Contracts/SortMethodFactoryInterface.php b/packages/queries/src/Contracts/SortMethodFactoryInterface.php index 6e192d0a..a9ea0fe3 100644 --- a/packages/queries/src/Contracts/SortMethodFactoryInterface.php +++ b/packages/queries/src/Contracts/SortMethodFactoryInterface.php @@ -5,7 +5,7 @@ namespace EDT\Querying\Contracts; /** - * @template TSorting of PathsBasedInterface + * @template TSorting */ interface SortMethodFactoryInterface { @@ -16,7 +16,7 @@ interface SortMethodFactoryInterface * * @throws PathException */ - public function propertyAscending(string|array|PropertyPathInterface $properties): PathsBasedInterface; + public function propertyAscending(string|array|PropertyPathInterface $properties); /** * @param non-empty-string|non-empty-list|PropertyPathInterface $properties @@ -25,5 +25,5 @@ public function propertyAscending(string|array|PropertyPathInterface $properties * * @throws PathException */ - public function propertyDescending(string|array|PropertyPathInterface $properties): PathsBasedInterface; + public function propertyDescending(string|array|PropertyPathInterface $properties); } diff --git a/packages/queries/src/FluentQueries/ConditionDefinition.php b/packages/queries/src/FluentQueries/ConditionDefinition.php index e06a2d7f..4a51a30f 100644 --- a/packages/queries/src/FluentQueries/ConditionDefinition.php +++ b/packages/queries/src/FluentQueries/ConditionDefinition.php @@ -4,37 +4,31 @@ namespace EDT\Querying\FluentQueries; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; -use EDT\ConditionFactory\PathsBasedConditionGroupFactoryInterface; -use EDT\Querying\Contracts\PathsBasedInterface; +use EDT\ConditionFactory\DrupalFilterInterface; +use EDT\ConditionFactory\ConditionFactoryInterface; +use EDT\ConditionFactory\ConditionGroupFactoryInterface; use function count; -/** - * @template TCondition of PathsBasedInterface - */ class ConditionDefinition { /** - * @var list + * @var list */ protected array $conditions = []; /** - * @var list> + * @var list */ protected array $subDefinitions = []; /** - * @param PathsBasedConditionFactoryInterface&PathsBasedConditionGroupFactoryInterface $conditionFactory + * @param ConditionFactoryInterface&ConditionGroupFactoryInterface $conditionFactory */ public function __construct( - protected PathsBasedConditionFactoryInterface $conditionFactory, + protected ConditionFactoryInterface&ConditionGroupFactoryInterface $conditionFactory, protected bool $andConjunction ) {} - /** - * @return ConditionDefinition - */ public function anyConditionApplies(): ConditionDefinition { $subDefinition = new ConditionDefinition($this->conditionFactory, false); @@ -42,9 +36,6 @@ public function anyConditionApplies(): ConditionDefinition return $subDefinition; } - /** - * @return ConditionDefinition - */ public function allConditionsApply(): ConditionDefinition { $subDefinition = new ConditionDefinition($this->conditionFactory, true); @@ -63,10 +54,9 @@ public function propertyIsNull(array $properties): self } /** - * @param TCondition $condition * @return $this */ - protected function add(PathsBasedInterface $condition): self + protected function add(DrupalFilterInterface $condition): self { $this->conditions[] = $condition; return $this; @@ -301,7 +291,7 @@ public function propertyHasNotStringAsMember(string $value, array $properties): } /** - * @return list + * @return list */ public function getConditions(): array { @@ -324,7 +314,7 @@ public function getConditions(): array * **No {@link ConditionDefinition::conditions} property of any {@link ConditionDefinition} instance will be modified * in the process.** * - * @return list + * @return list */ protected function processSubDefinitions(): array { diff --git a/packages/queries/src/FluentQueries/FluentQuery.php b/packages/queries/src/FluentQueries/FluentQuery.php index 2dc09ea0..e48eb1c2 100644 --- a/packages/queries/src/FluentQueries/FluentQuery.php +++ b/packages/queries/src/FluentQueries/FluentQuery.php @@ -4,13 +4,14 @@ namespace EDT\Querying\FluentQueries; +use EDT\ConditionFactory\DrupalFilterInterface; use EDT\Querying\Contracts\OffsetEntityProviderInterface; use EDT\Querying\Contracts\FluentQueryException; use EDT\Querying\Contracts\PathException; use EDT\Querying\Contracts\PaginationException; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\SortException; use EDT\Querying\Pagination\OffsetPagination; +use EDT\Querying\SortMethodFactories\SortMethodInterface; use const PHP_INT_MAX; /** @@ -22,16 +23,12 @@ * You may want to implement a factory to create instances of this class instead of using * its constructor, to avoid manually providing the same parameters on every usage. * - * @template TCondition of PathsBasedInterface - * @template TSorting of PathsBasedInterface * @template TEntity of object */ class FluentQuery { /** - * @param OffsetEntityProviderInterface $objectProvider - * @param ConditionDefinition $conditionDefinition - * @param SortDefinition $sortDefinition + * @param OffsetEntityProviderInterface $objectProvider */ public function __construct( protected readonly OffsetEntityProviderInterface $objectProvider, @@ -88,17 +85,11 @@ public function getUniqueEntity(): ?object return $first; } - /** - * @return SortDefinition - */ public function getSortDefinition(): SortDefinition { return $this->sortDefinition; } - /** - * @return ConditionDefinition - */ public function getConditionDefinition(): ConditionDefinition { return $this->conditionDefinition; diff --git a/packages/queries/src/FluentQueries/SortDefinition.php b/packages/queries/src/FluentQueries/SortDefinition.php index 89bb20a0..59b5f33e 100644 --- a/packages/queries/src/FluentQueries/SortDefinition.php +++ b/packages/queries/src/FluentQueries/SortDefinition.php @@ -4,21 +4,18 @@ namespace EDT\Querying\FluentQueries; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\SortMethodFactoryInterface; +use EDT\Querying\SortMethodFactories\SortMethodInterface; -/** - * @template TSorting of PathsBasedInterface - */ class SortDefinition { /** - * @var list + * @var list */ private array $sortMethods = []; /** - * @param SortMethodFactoryInterface $sortMethodFactory + * @param SortMethodFactoryInterface $sortMethodFactory */ public function __construct( protected readonly SortMethodFactoryInterface $sortMethodFactory @@ -47,7 +44,7 @@ public function propertyDescending(array $properties): self } /** - * @return list + * @return list */ public function getSortMethods(): array { diff --git a/packages/queries/src/ObjectProviders/MutableEntityProvider.php b/packages/queries/src/ObjectProviders/MutableEntityProvider.php new file mode 100644 index 00000000..eee8fc81 --- /dev/null +++ b/packages/queries/src/ObjectProviders/MutableEntityProvider.php @@ -0,0 +1,66 @@ + + */ +class MutableEntityProvider extends PrefilledEntityProvider +{ + /** + * @param list $entities + */ + public function __construct(ConditionEvaluator $conditionEvaluator, Sorter $sorter, array $entities = []) + { + parent::__construct($conditionEvaluator, $sorter, $entities); + } + + /** + * Add the given entity to this provider. + * + * No check is done if the entity already exists in this provider. I.e. adding the same entity multiple times may + * result in it being returned multiple times via {@link getEntities()}. + * + * @param TEntity $entity + */ + public function addEntity(object $entity): void + { + $this->entities[] = $entity; + } + + /** + * Remove all entities that match all the given conditions each. + * + * @param list> $conditions + * @param positive-int|null $expectedCount if non-`null`, execute the removal only if exactly this number of + * entities match the given conditions and thrown an exception if not + * + * @return int<0,max> + */ + public function removeEntities(array $conditions, int $expectedCount = null): int + { + $newList = array_values(array_filter( + $this->entities, + fn(object $entity): bool => !$this->conditionEvaluator->evaluateConditions($entity, $conditions) + )); + + $removalCount = count($this->entities) - count($newList); + Assert::greaterThanEq($removalCount, 0); + if (null !== $expectedCount && $removalCount !== $expectedCount) { + throw new InvalidArgumentException("Expected $expectedCount entities to be removed by matching the given conditions, found $removalCount matching entities instead."); + } + $this->entities = $newList; + + return $removalCount; + } +} diff --git a/packages/queries/src/ObjectProviders/PrefilledEntityProvider.php b/packages/queries/src/ObjectProviders/PrefilledEntityProvider.php index a1197c1f..d52a82a2 100644 --- a/packages/queries/src/ObjectProviders/PrefilledEntityProvider.php +++ b/packages/queries/src/ObjectProviders/PrefilledEntityProvider.php @@ -4,12 +4,12 @@ namespace EDT\Querying\ObjectProviders; -use EDT\Querying\Contracts\OffsetEntityProviderInterface; -use EDT\Querying\Pagination\OffsetPagination; use EDT\Querying\Contracts\FunctionInterface; +use EDT\Querying\Contracts\OffsetEntityProviderInterface; use EDT\Querying\Contracts\PaginationException; use EDT\Querying\Contracts\SortException; use EDT\Querying\Contracts\SortMethodInterface; +use EDT\Querying\Pagination\OffsetPagination; use EDT\Querying\Utilities\ConditionEvaluator; use EDT\Querying\Utilities\Sorter; use function array_slice; @@ -22,17 +22,17 @@ class PrefilledEntityProvider implements OffsetEntityProviderInterface { /** - * @param list $prefilledArray + * @param list $entities */ public function __construct( protected readonly ConditionEvaluator $conditionEvaluator, protected readonly Sorter $sorter, - protected readonly array $prefilledArray + protected array $entities = [] ) {} public function getEntities(array $conditions, array $sortMethods, ?OffsetPagination $pagination): array { - $result = $this->prefilledArray; + $result = $this->entities; $result = $this->filter($result, $conditions); $result = $this->sort($result, $sortMethods); @@ -54,11 +54,11 @@ protected function sort(array $list, array $sortMethods): array return $list; } - return array_values($this->sorter->sortArray($list, $sortMethods)); + return $this->sorter->sortArray($list, $sortMethods); } /** - * @param list $list + * @param list $list * @param list> $conditions * * @return list @@ -66,7 +66,7 @@ protected function sort(array $list, array $sortMethods): array protected function filter(array $list, array $conditions): array { if ([] !== $conditions) { - $list = array_values($this->conditionEvaluator->filterArray($list, ...$conditions)); + return $this->conditionEvaluator->filterArray($list, ...$conditions); } return $list; @@ -74,8 +74,8 @@ protected function filter(array $list, array $conditions): array /** * @param list $list - * @param int<0, max> $offset - * @param int<0, max>|null $limit + * @param int<0, max> $offset + * @param int<0, max>|null $limit * * @return list * @throws PaginationException @@ -83,7 +83,7 @@ protected function filter(array $list, array $conditions): array protected function slice(array $list, int $offset, ?int $limit): array { if (0 !== $offset || null !== $limit) { - $list = array_slice($list, $offset, $limit); + return array_slice($list, $offset, $limit); } return $list; diff --git a/packages/queries/src/SortMethodFactories/PhpSortMethodFactory.php b/packages/queries/src/SortMethodFactories/PhpSortMethodFactory.php index 16ed1dd1..aba51742 100644 --- a/packages/queries/src/SortMethodFactories/PhpSortMethodFactory.php +++ b/packages/queries/src/SortMethodFactories/PhpSortMethodFactory.php @@ -4,7 +4,6 @@ namespace EDT\Querying\SortMethodFactories; -use EDT\Querying\Contracts\PathsBasedInterface; use EDT\Querying\Contracts\PropertyPathAccessInterface; use EDT\Querying\Contracts\PropertyPathInterface; use EDT\Querying\Contracts\SortMethodFactoryInterface; @@ -19,13 +18,13 @@ */ class PhpSortMethodFactory implements SortMethodFactoryInterface { - public function propertyAscending(string|array|PropertyPathInterface $properties): PathsBasedInterface + public function propertyAscending(string|array|PropertyPathInterface $properties) { $propertyPathInstance = new PropertyPath(null, '', PropertyPathAccessInterface::UNPACK_RECURSIVE, $properties); return new Ascending(new Property($propertyPathInstance)); } - public function propertyDescending(string|array|PropertyPathInterface $properties): PathsBasedInterface + public function propertyDescending(string|array|PropertyPathInterface $properties) { $propertyPathInstance = new PropertyPath(null, '', PropertyPathAccessInterface::UNPACK_RECURSIVE, $properties); return new Descending(new Property($propertyPathInstance)); diff --git a/packages/queries/src/SortMethodFactories/SortMethod.php b/packages/queries/src/SortMethodFactories/SortMethod.php new file mode 100644 index 00000000..4a692ea5 --- /dev/null +++ b/packages/queries/src/SortMethodFactories/SortMethod.php @@ -0,0 +1,56 @@ + + */ + protected array $path; + + /** + * @param non-empty-string|non-empty-list|PropertyPathInterface $path + * + * @internal + */ + public function __construct(array|string|PropertyPathInterface $path, protected readonly bool $descending) + { + $this->path = self::pathToArray($path); + } + + /** + * @param non-empty-string|non-empty-list|PropertyPathInterface $properties + */ + public static function ascendingByPath(array|string|PropertyPathInterface $properties): self + { + return new self($properties, false); + } + + /** + * @param non-empty-string|non-empty-list|PropertyPathInterface $properties + */ + public static function descendingByPath(array|string|PropertyPathInterface $properties): self + { + return new self($properties, true); + } + + public function adjustPath(callable $callable): void + { + $this->path = $callable($this->path); + } + + public function getAsString(): string + { + $pathString = self::pathToString($this->path); + return $this->descending ? "-$pathString" : $pathString; + } +} diff --git a/packages/queries/src/SortMethodFactories/SortMethodFactory.php b/packages/queries/src/SortMethodFactories/SortMethodFactory.php new file mode 100644 index 00000000..34a7918b --- /dev/null +++ b/packages/queries/src/SortMethodFactories/SortMethodFactory.php @@ -0,0 +1,24 @@ + + */ +class SortMethodFactory implements SortMethodFactoryInterface +{ + public function propertyAscending(array|string|PropertyPathInterface $properties) + { + return SortMethod::ascendingByPath($properties); + } + + public function propertyDescending(array|string|PropertyPathInterface $properties) + { + return SortMethod::descendingByPath($properties); + } +} diff --git a/packages/queries/src/SortMethodFactories/SortMethodInterface.php b/packages/queries/src/SortMethodFactories/SortMethodInterface.php new file mode 100644 index 00000000..12a89113 --- /dev/null +++ b/packages/queries/src/SortMethodFactories/SortMethodInterface.php @@ -0,0 +1,17 @@ + $this->evaluateConditions($value, $conditions)); + return array_values(array_filter($arrayToFilter, fn (object $value): bool => $this->evaluateConditions($value, $conditions))); } /** * @param list> $conditions * + * @return bool `true` if the given object matches each of the given conditions; `false` otherwise + * * @throws PathException * @throws InvalidArgumentException */ diff --git a/packages/queries/src/Utilities/PathConverterTrait.php b/packages/queries/src/Utilities/PathConverterTrait.php new file mode 100644 index 00000000..a6c8df22 --- /dev/null +++ b/packages/queries/src/Utilities/PathConverterTrait.php @@ -0,0 +1,83 @@ + + * + * @throws InvalidArgumentException + */ + protected static function inputPathToArray(mixed $inputPath): array + { + if (is_string($inputPath)) { + $path = explode('.', $inputPath); + Assert::allStringNotEmpty($path, "Invalid path `$inputPath`, contains empty segments."); + + return $path; + } + + if (is_array($inputPath)) { + Assert::isNonEmptyList($inputPath); + Assert::allStringNotEmpty($inputPath); + + return $inputPath; + } + + if ($inputPath instanceof PropertyPathInterface) { + return $inputPath->getAsNames(); + } + + throw new InvalidArgumentException('Invalid input path provided'); + } + + /** + * @param non-empty-string|non-empty-list|PropertyPathInterface $inputPath + * + * @return non-empty-list + * + * @throws InvalidArgumentException + */ + protected static function pathToArray(string|array|PropertyPathInterface $inputPath): array + { + if (is_string($inputPath)) { + $path = explode('.', $inputPath); + Assert::allStringNotEmpty($path, "Invalid path `$inputPath`, contains empty segments."); + + return $path; + } + + if (is_array($inputPath)) { + return $inputPath; + } + + return $inputPath->getAsNames(); + } + + /** + * @param non-empty-string|non-empty-list|PropertyPathInterface $path + * + * @return non-empty-string + */ + protected static function pathToString(string|array|PropertyPathInterface $path): string + { + if (is_string($path)) { + return $path; + } + + if (is_array($path)) { + return implode('.', $path); + } + + return $path->getAsNamesInDotNotation(); + } +} diff --git a/packages/queries/src/Utilities/Sorter.php b/packages/queries/src/Utilities/Sorter.php index 3895b257..aac45602 100644 --- a/packages/queries/src/Utilities/Sorter.php +++ b/packages/queries/src/Utilities/Sorter.php @@ -56,7 +56,7 @@ public function sortArray(array $entitiesToSort, array $sortMethods): array return 0; }); - return $entitiesToSort; + return array_values($entitiesToSort); } catch (Throwable $exception) { throw SortException::forCountAndMethods($exception, count($entitiesToSort), $sortMethods); } diff --git a/packages/queries/tests/Querying/Evaluators/ConditionEvaluatorTest.php b/packages/queries/tests/Querying/Evaluators/ConditionEvaluatorTest.php index f09628e8..17f2570d 100644 --- a/packages/queries/tests/Querying/Evaluators/ConditionEvaluatorTest.php +++ b/packages/queries/tests/Querying/Evaluators/ConditionEvaluatorTest.php @@ -22,6 +22,7 @@ use EDT\Querying\Utilities\TableJoiner; use Tests\ModelBasedTest; use TypeError; +use Webmozart\Assert\Assert; class ConditionEvaluatorTest extends ModelBasedTest { @@ -59,8 +60,13 @@ public function testAllConditionsApplyWithTwo(): void public function testAlwaysTrue(): void { $alwaysTrue = $this->conditionFactory->true(); - $filteredAuthors = $this->conditionEvaluator->filterArray($this->authors, $alwaysTrue); - self::assertEquals($this->authors, $filteredAuthors); + $authorValues = array_values($this->authors); + $filteredAuthors = $this->conditionEvaluator->filterArray($authorValues, $alwaysTrue); + $count = count($filteredAuthors); + self::assertCount($count, $authorValues); + for ($i = 0; $i < $count; $i++) { + self::assertSame($authorValues[$i], $authorValues[$i]); + } } public function testAlwaysFalse(): void @@ -83,8 +89,13 @@ public function testAnyConditionApplies(): void public function testInvertedConditionApplies(): void { $alwaysTrue = new InvertedBoolean($this->conditionFactory->false()); - $filteredAuthors = $this->conditionEvaluator->filterArray($this->authors, $alwaysTrue); - self::assertEquals($this->authors, $filteredAuthors); + $authorValues = array_values($this->authors); + $filteredAuthors = $this->conditionEvaluator->filterArray($authorValues, $alwaysTrue); + $count = count($filteredAuthors); + self::assertCount($count, $authorValues); + for ($i = 0; $i < $count; $i++) { + self::assertSame($authorValues[$i], $authorValues[$i]); + } } public function testPropertiesEqual(): void diff --git a/packages/queries/tests/Querying/FluentQueries/FetchRequestBuilderFactoryTest.php b/packages/queries/tests/Querying/FluentQueries/FetchRequestBuilderFactoryTest.php index 6548e340..597e3214 100644 --- a/packages/queries/tests/Querying/FluentQueries/FetchRequestBuilderFactoryTest.php +++ b/packages/queries/tests/Querying/FluentQueries/FetchRequestBuilderFactoryTest.php @@ -4,42 +4,55 @@ namespace Tests\Querying\FluentQueries; +use EDT\ConditionFactory\ConditionFactory; +use EDT\JsonApi\InputHandling\ConditionConverter; +use EDT\JsonApi\InputHandling\PhpEntityRepository; +use EDT\JsonApi\InputHandling\SortMethodConverter; +use EDT\JsonApi\RequestHandling\JsonApiSortingParser; +use EDT\JsonApi\Validation\SortValidator; use EDT\Querying\ConditionFactories\PhpConditionFactory; +use EDT\Querying\ConditionParsers\Drupal\DrupalConditionParser; +use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; +use EDT\Querying\ConditionParsers\Drupal\DrupalFilterValidator; +use EDT\Querying\ConditionParsers\Drupal\PredefinedDrupalConditionFactory; use EDT\Querying\Contracts\FluentQueryException; use EDT\Querying\Contracts\FunctionInterface; +use EDT\Querying\Contracts\OffsetEntityProviderInterface; use EDT\Querying\Contracts\SortMethodInterface; use EDT\Querying\FluentQueries\ConditionDefinition; use EDT\Querying\FluentQueries\SliceDefinition; use EDT\Querying\FluentQueries\SortDefinition; +use EDT\Querying\ObjectProviders\MutableEntityProvider; use EDT\Querying\ObjectProviders\PrefilledEntityProvider; +use EDT\Querying\Pagination\OffsetPagination; use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; use EDT\Querying\FluentQueries\FluentQuery; use EDT\Querying\SortMethodFactories\PhpSortMethodFactory; +use EDT\Querying\SortMethodFactories\SortMethodFactory; use EDT\Querying\Utilities\ConditionEvaluator; +use EDT\Querying\Utilities\Reindexer; use EDT\Querying\Utilities\Sorter; use EDT\Querying\Utilities\TableJoiner; +use Symfony\Component\Validator\Validation; use Tests\data\Model\Person; use Tests\ModelBasedTest; class FetchRequestBuilderFactoryTest extends ModelBasedTest { - private PhpConditionFactory $conditionFactory; - - private PrefilledEntityProvider $authorProvider; - - private PhpSortMethodFactory $sortMethodFactory; + private MutableEntityProvider $authorProvider; protected function setUp(): void { parent::setUp(); - $this->conditionFactory = new PhpConditionFactory(); $propertyAccessor = new ReflectionPropertyAccessor(); - $this->authorProvider = new PrefilledEntityProvider( - new ConditionEvaluator(new TableJoiner($propertyAccessor)), - new Sorter(new TableJoiner($propertyAccessor)), + $tableJoiner = new TableJoiner($propertyAccessor); + $conditionEvaluator = new ConditionEvaluator($tableJoiner); + $sorter = new Sorter($tableJoiner); + $this->authorProvider = new MutableEntityProvider( + $conditionEvaluator, + $sorter, $this->authors ); - $this->sortMethodFactory = new PhpSortMethodFactory(); } /** @@ -48,9 +61,21 @@ protected function setUp(): void protected function createFetchRequest(): FluentQuery { return new FluentQuery( - $this->authorProvider, - new ConditionDefinition($this->conditionFactory, true), - new SortDefinition($this->sortMethodFactory), + new class ($this->authorProvider) implements OffsetEntityProviderInterface { + public function __construct(protected readonly MutableEntityProvider $entityProvider){} + + public function getEntities(array $conditions, array $sortMethods, ?OffsetPagination $pagination): array + { + $conditionConverter = ConditionConverter::createDefault(Validation::createValidator(), new PhpConditionFactory()); + $sortMethodConverter = SortMethodConverter::createDefault(Validation::createValidator(), new PhpSortMethodFactory()); + $conditions = $conditionConverter->convertConditions($conditions); + $sortMethods = $sortMethodConverter->convertSortMethods($sortMethods); + + return $this->entityProvider->getEntities($conditions, $sortMethods, $pagination); + } + }, + new ConditionDefinition(new ConditionFactory(), true), + new SortDefinition(new SortMethodFactory()), new SliceDefinition() ); } diff --git a/packages/queries/tests/Querying/ObjectProviders/PrefilledObjectProviderTest.php b/packages/queries/tests/Querying/ObjectProviders/PrefilledObjectProviderTest.php index 1efbd226..53cc03d6 100644 --- a/packages/queries/tests/Querying/ObjectProviders/PrefilledObjectProviderTest.php +++ b/packages/queries/tests/Querying/ObjectProviders/PrefilledObjectProviderTest.php @@ -4,12 +4,21 @@ namespace Tests\Querying\ObjectProviders; +use EDT\JsonApi\RequestHandling\JsonApiSortingParser; +use EDT\JsonApi\Validation\SortValidator; +use EDT\Querying\ConditionFactories\PhpConditionFactory; +use EDT\Querying\ConditionParsers\Drupal\DrupalConditionParser; +use EDT\Querying\ConditionParsers\Drupal\DrupalFilterParser; +use EDT\Querying\ConditionParsers\Drupal\DrupalFilterValidator; +use EDT\Querying\ConditionParsers\Drupal\PredefinedDrupalConditionFactory; use EDT\Querying\ObjectProviders\PrefilledEntityProvider; use EDT\Querying\Pagination\OffsetPagination; use EDT\Querying\PropertyAccessors\ReflectionPropertyAccessor; +use EDT\Querying\SortMethodFactories\PhpSortMethodFactory; use EDT\Querying\Utilities\ConditionEvaluator; use EDT\Querying\Utilities\Sorter; use EDT\Querying\Utilities\TableJoiner; +use Symfony\Component\Validator\Validation; use Tests\data\Model\Person; use Tests\ModelBasedTest; @@ -62,6 +71,14 @@ protected function setUp(): void parent::setUp(); $propertyAccessor = new ReflectionPropertyAccessor(); + $validator = Validation::createValidator(); + $phpConditionFactory = new PhpConditionFactory(); + $drupalConditionFactory = new PredefinedDrupalConditionFactory($phpConditionFactory); + $filterValidator = new DrupalFilterValidator($validator, $drupalConditionFactory); + $filterTransformer = new DrupalFilterParser($phpConditionFactory, new DrupalConditionParser($drupalConditionFactory), $filterValidator); + $phpSortMethodFactory = new PhpSortMethodFactory(); + $sortingTransformer = new JsonApiSortingParser($phpSortMethodFactory); + $sortingValidator = new SortValidator($validator); $this->authorProvider = new PrefilledEntityProvider( new ConditionEvaluator(new TableJoiner($propertyAccessor)), new Sorter(new TableJoiner($propertyAccessor)), diff --git a/packages/queries/tests/Querying/Utilities/PathTransformerTest.php b/packages/queries/tests/Querying/Utilities/PathTransformerTest.php index 22a89472..f2ec91fa 100644 --- a/packages/queries/tests/Querying/Utilities/PathTransformerTest.php +++ b/packages/queries/tests/Querying/Utilities/PathTransformerTest.php @@ -4,14 +4,14 @@ namespace Tests\Querying\Utilities; +use EDT\ConditionFactory\ConditionFactoryInterface; use EDT\Querying\ConditionFactories\PhpConditionFactory; -use EDT\ConditionFactory\PathsBasedConditionFactoryInterface; use EDT\Querying\Utilities\PathTransformer; use PHPUnit\Framework\TestCase; class PathTransformerTest extends TestCase { - private PathsBasedConditionFactoryInterface $conditionFactory; + private ConditionFactoryInterface $conditionFactory; private PathTransformer $pathTransformer; diff --git a/phpstan.neon b/phpstan.neon index 2b415415..c1eda650 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -51,16 +51,6 @@ parameters: # Note: use `\w+(\\\w+)+\\(\w+)` to `$2` replacement to remove namespaces in phpstan error messages, making it a bit more readable # Note: use `grep path: phpstan.neon | sort | uniq -c | awk '{print $1} {print $3}'` to get the list of classes with their count of errors ignoreErrors: - - - message: "#^Method EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\ToMany\\\\ToManyRelationshipConstructorBehavior\\:\\:createFactory\\(\\) should return EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipConstructorBehaviorFactoryInterface\\ but returns class@anonymous/access\\-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipConstructorBehavior\\.php\\:66\\.$#" - count: 1 - path: packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToMany/ToManyRelationshipConstructorBehavior.php - - - - message: "#^Method EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\ToOne\\\\ToOneRelationshipConstructorBehavior\\:\\:createFactory\\(\\) should return EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipConstructorBehaviorFactoryInterface\\ but returns class@anonymous/access\\-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipConstructorBehavior\\.php\\:66\\.$#" - count: 1 - path: packages/access-definitions/src/Wrapping/PropertyBehavior/Relationship/ToOne/ToOneRelationshipConstructorBehavior.php - - message: "#^Parameter \\#1 \\$baseFunction of class EDT\\\\DqlQuerying\\\\Functions\\\\LowerCase constructor expects EDT\\\\DqlQuerying\\\\Contracts\\\\ClauseFunctionInterface\\, EDT\\\\DqlQuerying\\\\Functions\\\\Value\\ given\\.$#" count: 3 @@ -305,12 +295,12 @@ parameters: path: packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilder.php - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\\\|bool\\|float\\|int\\|string\\|null,EDT\\\\Wrapping\\\\PropertyBehavior\\\\ConstructorBehaviorFactoryInterface,EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\\\>\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Attribute\\\\Factory\\\\PathAttributeSetBehaviorFactory\\ given\\.$#" + message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\\\|bool\\|float\\|int\\|string\\|null,EDT\\\\Wrapping\\\\PropertyBehavior\\\\ConstructorBehaviorFactoryInterface,EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\\\>\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Attribute\\\\Factory\\\\PathAttributeSetBehaviorFactory\\ given\\.$#" count: 1 path: packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilder.php - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\\\|bool\\|float\\|int\\|string\\|null,EDT\\\\Wrapping\\\\PropertyBehavior\\\\ConstructorBehaviorFactoryInterface,EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\\\>\\:\\:addUpdateBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Attribute\\\\Factory\\\\PathAttributeSetBehaviorFactory\\ given\\.$#" + message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\\\|bool\\|float\\|int\\|string\\|null,EDT\\\\Wrapping\\\\PropertyBehavior\\\\ConstructorBehaviorFactoryInterface,EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\\\>\\:\\:addUpdateBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\PropertyUpdatabilityFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Attribute\\\\Factory\\\\PathAttributeSetBehaviorFactory\\ given\\.$#" count: 1 path: packages/jsonapi/src/PropertyConfig/Builder/AttributeConfigBuilder.php @@ -323,7 +313,7 @@ parameters: path: packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilder.php - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\IdentifierConfigBuilder\\\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Identifier\\\\Factory\\\\IdentifierPostConstructorBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Identifier\\\\Factory\\\\IdentifierPostConstructorBehaviorFactoryInterface\\ given\\.$#" + message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\IdentifierConfigBuilder\\\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Identifier\\\\Factory\\\\IdentifierPostConstructorBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Identifier\\\\Factory\\\\IdentifierPostConstructorBehaviorFactoryInterface\\ given\\.$#" count: 1 path: packages/jsonapi/src/PropertyConfig/Builder/IdentifierConfigBuilder.php @@ -344,37 +334,27 @@ parameters: path: packages/jsonapi/src/PropertyConfig/Builder/RelationshipConfigBuilder.php - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipConstructorBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" + message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipConstructorBehaviorFactoryInterface,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" count: 1 path: packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilder.php - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipConstructorBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" + message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipConstructorBehaviorFactoryInterface,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addUpdateBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" count: 1 path: packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilder.php - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipConstructorBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addUpdateBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" - count: 1 - path: packages/jsonapi/src/PropertyConfig/Builder/ToManyRelationshipConfigBuilder.php - - - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" + message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" count: 1 path: packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilder.php - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addCreationBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" + message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addUpdateBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" count: 1 path: packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilder.php - - message: "#^Parameter \\#1 \\$behaviorFactory of method EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AbstractPropertyConfigBuilder\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\,EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\\\>\\:\\:addUpdateBehavior\\(\\) expects EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\, EDT\\\\Wrapping\\\\PropertyBehavior\\\\Relationship\\\\RelationshipSetBehaviorFactoryInterface\\ given\\.$#" - count: 1 - path: packages/jsonapi/src/PropertyConfig/Builder/ToOneRelationshipConfigBuilder.php - - - - message: "#^Parameter \\#1 \\$filterParser of class EDT\\\\JsonApi\\\\Requests\\\\ListRequest constructor expects EDT\\\\JsonApi\\\\RequestHandling\\\\FilterParserInterface\\, EDT\\\\Querying\\\\ConditionParsers\\\\Drupal\\\\DrupalFilterParser\\ given\\.$#" + message: "#^Parameter \\#1 \\$filterParser of class EDT\\\\JsonApi\\\\Requests\\\\ListRequest constructor expects EDT\\\\JsonApi\\\\RequestHandling\\\\FilterParserInterface\\, EDT\\\\Querying\\\\ConditionParsers\\\\Drupal\\\\DrupalFilterParser\\ given\\.$#" count: 1 path: packages/jsonapi/src/Requests/ListProcessor.php @@ -386,26 +366,6 @@ parameters: count: 1 path: packages/jsonapi/src/Requests/ListRequest.php - - - message: "#^Method EDT\\\\JsonApi\\\\Utilities\\\\PropertyBuilderFactory\\:\\:createAttribute\\(\\) should return EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AttributeConfigBuilder\\ but returns EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\AttributeConfigBuilder\\\\.$#" - count: 1 - path: packages/jsonapi/src/Utilities/PropertyBuilderFactory.php - - - - message: "#^Method EDT\\\\JsonApi\\\\Utilities\\\\PropertyBuilderFactory\\:\\:createIdentifier\\(\\) should return EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\IdentifierConfigBuilder\\ but returns EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\IdentifierConfigBuilder\\\\.$#" - count: 1 - path: packages/jsonapi/src/Utilities/PropertyBuilderFactory.php - - - - message: "#^Method EDT\\\\JsonApi\\\\Utilities\\\\PropertyBuilderFactory\\:\\:createToManyWithType\\(\\) should return EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\ToManyRelationshipConfigBuilder\\ but returns EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\ToManyRelationshipConfigBuilder\\\\.$#" - count: 1 - path: packages/jsonapi/src/Utilities/PropertyBuilderFactory.php - - - - message: "#^Method EDT\\\\JsonApi\\\\Utilities\\\\PropertyBuilderFactory\\:\\:createToOneWithType\\(\\) should return EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\ToOneRelationshipConfigBuilder\\ but returns EDT\\\\JsonApi\\\\PropertyConfig\\\\Builder\\\\ToOneRelationshipConfigBuilder\\\\.$#" - count: 1 - path: packages/jsonapi/src/Utilities/PropertyBuilderFactory.php - - message: "#^Method EDT\\\\JsonApi\\\\Validation\\\\FieldsValidator\\:\\:validateFormat\\(\\) should return array\\ but returns array\\.$#" count: 1 @@ -521,11 +481,6 @@ parameters: count: 1 path: packages/queries/src/ConditionFactories/PhpConditionFactory.php - - - message: "#^Method EDT\\\\Querying\\\\FluentQueries\\\\ConditionDefinition\\:\\:false\\(\\) return type with generic class EDT\\\\Querying\\\\FluentQueries\\\\ConditionDefinition does not specify its types\\: TCondition$#" - count: 1 - path: packages/queries/src/FluentQueries/ConditionDefinition.php - - message: "#^Method EDT\\\\Querying\\\\PropertyPaths\\\\PropertyPath\\:\\:getIterator\\(\\) should return Traversable\\ but returns ArrayIterator\\\\|ArrayIterator\\\\.$#" count: 1