Skip to content

Commit 242b25a

Browse files
authored
Enhanced contracts' PHPDoc (#463)
For more details see #463 Key changes: * Enhance `DateMetadata::TRASHED` phpdoc * Enhance `Criterion::getSpecifications()` phpdoc * Enhance `Specifications` phpdoc * Capable.php: Fix phpdoc summary * VersionBuilder.php: Fix phpdoc summary, arrays and self usages * ConstraintViolationAdapter's PHPDoc: Add a summary, reword description * Enhance `Criterion::getSpecifications()` phpdoc * Enhance `DateMetadata::TRASHED` phpdoc * Enhance `DateMetadata` phpdoc * Enhance `UserMetadata` phpdoc * Enhance `DateMetadata` phpdoc * Enhance `Capable` phpdoc * Enhance `Criterion` phpdoc * Enhance `UserMetadata` phpdoc (fix typo) * Enhance `UserMetadata` phpdoc * Enhance `FieldType\Generic\Type` phpdoc * Enhance `Limitation\Type` phpdoc * LocationService: Fix count() phpdoc * Enhance `LocationService` phpdoc * Enhance `Location` phpdoc * Enhance `Location` phpdoc: @deprecated can't be nested nor used inline. * Enhance `Location` phpdoc: Add an internal link * Enhance `ValueObject` phpdoc * Enhance `FieldType\Generic\Type` phpdoc: Fix internal links * Enhance `FieldType\FieldType` phpdoc: Fix code blocks * `Limitation\Type`: type array keys * ValueObject: Format desc
1 parent b435700 commit 242b25a

File tree

16 files changed

+262
-296
lines changed

16 files changed

+262
-296
lines changed

phpstan-baseline.neon

Lines changed: 2 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -5140,11 +5140,6 @@ parameters:
51405140
count: 1
51415141
path: src/contracts/Limitation/Target/Builder/VersionBuilder.php
51425142

5143-
-
5144-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Limitation\\\\Target\\\\DestinationLocation\\:\\:__construct\\(\\) has parameter \\$properties with no value type specified in iterable type array\\.$#"
5145-
count: 1
5146-
path: src/contracts/Limitation/Target/DestinationLocation.php
5147-
51485143
-
51495144
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Limitation\\\\Type\\:\\:acceptValue\\(\\) has no return type specified\\.$#"
51505145
count: 1
@@ -5275,11 +5270,6 @@ parameters:
52755270
count: 1
52765271
path: src/contracts/Persistence/Content/Type.php
52775272

5278-
-
5279-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Type\\\\FieldDefinition\\:\\:__construct\\(\\) has parameter \\$properties with no value type specified in iterable type array\\.$#"
5280-
count: 1
5281-
path: src/contracts/Persistence/Content/Type/FieldDefinition.php
5282-
52835273
-
52845274
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Type\\\\Handler\\:\\:delete\\(\\) has no return type specified\\.$#"
52855275
count: 1
@@ -5575,26 +5565,6 @@ parameters:
55755565
count: 1
55765566
path: src/contracts/Repository/Decorator/LocationServiceDecorator.php
55775567

5578-
-
5579-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Decorator\\\\SearchServiceDecorator\\:\\:findContent\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
5580-
count: 1
5581-
path: src/contracts/Repository/Decorator/SearchServiceDecorator.php
5582-
5583-
-
5584-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Decorator\\\\SearchServiceDecorator\\:\\:findContentInfo\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
5585-
count: 1
5586-
path: src/contracts/Repository/Decorator/SearchServiceDecorator.php
5587-
5588-
-
5589-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Decorator\\\\SearchServiceDecorator\\:\\:findLocations\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
5590-
count: 1
5591-
path: src/contracts/Repository/Decorator/SearchServiceDecorator.php
5592-
5593-
-
5594-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Decorator\\\\SearchServiceDecorator\\:\\:findSingle\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
5595-
count: 1
5596-
path: src/contracts/Repository/Decorator/SearchServiceDecorator.php
5597-
55985568
-
55995569
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Decorator\\\\SearchServiceDecorator\\:\\:suggest\\(\\) has no return type specified\\.$#"
56005570
count: 1
@@ -6865,26 +6835,6 @@ parameters:
68656835
count: 1
68666836
path: src/contracts/Repository/PermissionCriterionResolver.php
68676837

6868-
-
6869-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\SearchService\\:\\:findContent\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
6870-
count: 1
6871-
path: src/contracts/Repository/SearchService.php
6872-
6873-
-
6874-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\SearchService\\:\\:findContentInfo\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
6875-
count: 1
6876-
path: src/contracts/Repository/SearchService.php
6877-
6878-
-
6879-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\SearchService\\:\\:findLocations\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
6880-
count: 1
6881-
path: src/contracts/Repository/SearchService.php
6882-
6883-
-
6884-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\SearchService\\:\\:findSingle\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
6885-
count: 1
6886-
path: src/contracts/Repository/SearchService.php
6887-
68886838
-
68896839
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\SearchService\\:\\:suggest\\(\\) has no return type specified\\.$#"
68906840
count: 1
@@ -7265,21 +7215,11 @@ parameters:
72657215
count: 1
72667216
path: src/contracts/Repository/Values/Content/Search/SearchResult.php
72677217

7268-
-
7269-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Search\\\\SearchResult\\:\\:__construct\\(\\) has parameter \\$properties with no value type specified in iterable type array\\.$#"
7270-
count: 1
7271-
path: src/contracts/Repository/Values/Content/Search/SearchResult.php
7272-
72737218
-
72747219
message: "#^Class Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Trash\\\\SearchResult implements generic interface IteratorAggregate but does not specify its types\\: TKey, TValue$#"
72757220
count: 1
72767221
path: src/contracts/Repository/Values/Content/Trash/SearchResult.php
72777222

7278-
-
7279-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Trash\\\\SearchResult\\:\\:__construct\\(\\) has parameter \\$properties with no value type specified in iterable type array\\.$#"
7280-
count: 1
7281-
path: src/contracts/Repository/Values/Content/Trash/SearchResult.php
7282-
72837223
-
72847224
message: "#^Class Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Trash\\\\TrashItemDeleteResultList implements generic interface IteratorAggregate but does not specify its types\\: TKey, TValue$#"
72857225
count: 1
@@ -7415,26 +7355,11 @@ parameters:
74157355
count: 1
74167356
path: src/contracts/Repository/Values/UserPreference/UserPreferenceList.php
74177357

7418-
-
7419-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:__construct\\(\\) has parameter \\$properties with no value type specified in iterable type array\\.$#"
7420-
count: 1
7421-
path: src/contracts/Repository/Values/ValueObject.php
7422-
74237358
-
74247359
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:attributes\\(\\) return type has no value type specified in iterable type array\\.$#"
74257360
count: 1
74267361
path: src/contracts/Repository/Values/ValueObject.php
74277362

7428-
-
7429-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:getProperties\\(\\) has parameter \\$dynamicProperties with no value type specified in iterable type array\\.$#"
7430-
count: 1
7431-
path: src/contracts/Repository/Values/ValueObject.php
7432-
7433-
-
7434-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:getProperties\\(\\) return type has no value type specified in iterable type array\\.$#"
7435-
count: 1
7436-
path: src/contracts/Repository/Values/ValueObject.php
7437-
74387363
-
74397364
message: "#^Parameter \\#2 \\$value of method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:__set\\(\\) expects string, null given\\.$#"
74407365
count: 1
@@ -20141,7 +20066,7 @@ parameters:
2014120066
path: src/lib/Repository/Mapper/RoleDomainMapper.php
2014220067

2014320068
-
20144-
message: "#^Parameter \\#1 \\$limitationValues of method Ibexa\\\\Contracts\\\\Core\\\\Limitation\\\\Type\\:\\:buildValue\\(\\) expects array, array\\|null given\\.$#"
20069+
message: "#^Parameter \\#1 \\$limitationValues of method Ibexa\\\\Contracts\\\\Core\\\\Limitation\\\\Type\\:\\:buildValue\\(\\) expects array\\<int, mixed\\>, array\\|null given\\.$#"
2014520070
count: 2
2014620071
path: src/lib/Repository/Mapper/RoleDomainMapper.php
2014720072

@@ -20321,7 +20246,7 @@ parameters:
2032120246
path: src/lib/Repository/Permission/PermissionResolver.php
2032220247

2032320248
-
20324-
message: "#^Parameter \\#1 \\$limitationValues of method Ibexa\\\\Contracts\\\\Core\\\\Limitation\\\\Type\\:\\:buildValue\\(\\) expects array, array\\|null given\\.$#"
20249+
message: "#^Parameter \\#1 \\$limitationValues of method Ibexa\\\\Contracts\\\\Core\\\\Limitation\\\\Type\\:\\:buildValue\\(\\) expects array\\<int, mixed\\>, array\\|null given\\.$#"
2032520250
count: 1
2032620251
path: src/lib/Repository/Permission/PermissionResolver.php
2032720252

@@ -20760,26 +20685,6 @@ parameters:
2076020685
count: 1
2076120686
path: src/lib/Repository/SiteAccessAware/Repository.php
2076220687

20763-
-
20764-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\SiteAccessAware\\\\SearchService\\:\\:findContent\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
20765-
count: 1
20766-
path: src/lib/Repository/SiteAccessAware/SearchService.php
20767-
20768-
-
20769-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\SiteAccessAware\\\\SearchService\\:\\:findContentInfo\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
20770-
count: 1
20771-
path: src/lib/Repository/SiteAccessAware/SearchService.php
20772-
20773-
-
20774-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\SiteAccessAware\\\\SearchService\\:\\:findLocations\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
20775-
count: 1
20776-
path: src/lib/Repository/SiteAccessAware/SearchService.php
20777-
20778-
-
20779-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\SiteAccessAware\\\\SearchService\\:\\:findSingle\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
20780-
count: 1
20781-
path: src/lib/Repository/SiteAccessAware/SearchService.php
20782-
2078320688
-
2078420689
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\SiteAccessAware\\\\SearchService\\:\\:suggest\\(\\) has no return type specified\\.$#"
2078520690
count: 1
@@ -21195,16 +21100,6 @@ parameters:
2119521100
count: 1
2119621101
path: src/lib/Repository/Values/Content/Content.php
2119721102

21198-
-
21199-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\:\\:getProperties\\(\\) has parameter \\$dynamicProperties with no value type specified in iterable type array\\.$#"
21200-
count: 1
21201-
path: src/lib/Repository/Values/Content/Content.php
21202-
21203-
-
21204-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\:\\:getProperties\\(\\) return type has no value type specified in iterable type array\\.$#"
21205-
count: 1
21206-
path: src/lib/Repository/Values/Content/Content.php
21207-
2120821103
-
2120921104
message: "#^Property Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\:\\:\\$fieldDefinitionTranslationMap has unknown class eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\Content\\\\Field as its type\\.$#"
2121021105
count: 1
@@ -37835,11 +37730,6 @@ parameters:
3783537730
count: 1
3783637731
path: tests/integration/Core/Repository/SearchServiceTest.php
3783737732

37838-
-
37839-
message: "#^Method Ibexa\\\\Tests\\\\Integration\\\\Core\\\\Repository\\\\SearchServiceTest\\:\\:testUserMetadataGroupHorizontalFilterContent\\(\\) has parameter \\$queryType with no type specified\\.$#"
37840-
count: 1
37841-
path: tests/integration/Core/Repository/SearchServiceTest.php
37842-
3784337733
-
3784437734
message: "#^Method Ibexa\\\\Tests\\\\Integration\\\\Core\\\\Repository\\\\SearchServiceTest\\:\\:testUserMetadataGroupHorizontalFilterLocation\\(\\) has no return type specified\\.$#"
3784537735
count: 1

src/contracts/FieldType/FieldType.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,20 @@ abstract public function getSettingsSchema();
100100
* It is considered best practice to return a hash map, which contains
101101
* rudimentary settings structures, like e.g. for the "ezstring" FieldType
102102
*
103-
* <code>
104-
* array(
105-
* 'stringLength' => array(
106-
* 'minStringLength' => array(
107-
* 'type' => 'int',
108-
* 'default' => 0,
109-
* ),
110-
* 'maxStringLength' => array(
111-
* 'type' => 'int'
112-
* 'default' => null,
113-
* )
114-
* ),
115-
* );
116-
* </code>
103+
* ```
104+
* [
105+
* 'stringLength' => [
106+
* 'minStringLength' => [
107+
* 'type' => 'int',
108+
* 'default' => 0,
109+
* ],
110+
* 'maxStringLength' => [
111+
* 'type' => 'int'
112+
* 'default' => null,
113+
* ],
114+
* ],
115+
* ];
116+
* ```
117117
*
118118
* @return mixed
119119
*/
@@ -360,22 +360,22 @@ abstract public function fromPersistenceValue(FieldValue $fieldValue);
360360
*
361361
* @param \Ibexa\Contracts\Core\FieldType\Value $value
362362
*
363-
* @return array Hash with relation type as key and array of destination content ids as value.
363+
* @return array Hash with relation type as key and array of destination content IDs as value.
364364
*
365365
* Example:
366-
* <code>
367-
* array(
368-
* \Ibexa\Contracts\Core\Repository\Values\Content\Relation::LINK => array(
369-
* "contentIds" => array( 12, 13, 14 ),
370-
* "locationIds" => array( 24 )
371-
* ),
372-
* \Ibexa\Contracts\Core\Repository\Values\Content\Relation::EMBED => array(
373-
* "contentIds" => array( 12 ),
374-
* "locationIds" => array( 24, 45 )
375-
* ),
376-
* \Ibexa\Contracts\Core\Repository\Values\Content\Relation::FIELD => array( 12 )
377-
* )
378-
* </code>
366+
* ```
367+
* [
368+
* \Ibexa\Contracts\Core\Repository\Values\Content\Relation::LINK => [
369+
* 'contentIds' => [12, 13, 14],
370+
* 'locationIds' => [24]
371+
* ],
372+
* \Ibexa\Contracts\Core\Repository\Values\Content\Relation::EMBED => [
373+
* 'contentIds" => [12],
374+
* 'locationIds' => [24, 45]
375+
* ],
376+
* \Ibexa\Contracts\Core\Repository\Values\Content\Relation::FIELD => [12]
377+
* ]
378+
* ```
379379
*/
380380
abstract public function getRelations(Value $value);
381381
}

src/contracts/FieldType/Generic/Type.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,20 @@ final public function acceptValue($inputValue): Value
260260
* If given $inputValue could not be converted or is already an instance of dedicate value object,
261261
* the method should simply return it.
262262
*
263-
* This is an operation method for {@see acceptValue()}.
263+
* This is an operation method for {@see Type::acceptValue()}.
264264
*
265265
* Example implementation:
266-
* <code>
267-
* protected function createValueFromInput( $inputValue )
266+
* ```
267+
* protected function createValueFromInput($inputValue)
268268
* {
269-
* if ( is_array( $inputValue ) )
269+
* if (is_array($inputValue))
270270
* {
271-
* $inputValue = \My\FieldType\CookieJar\Value( $inputValue );
271+
* $inputValue = \My\FieldType\CookieJar\Value($inputValue);
272272
* }
273273
*
274274
* return $inputValue;
275275
* }
276-
* </code>
276+
* ```
277277
*
278278
* @param mixed $inputValue
279279
*
@@ -304,23 +304,23 @@ protected function getValueClass(): string
304304
/**
305305
* Throws an exception if the given $value is not an instance of the supported value subtype.
306306
*
307-
* This is an operation method for {@see acceptValue()}.
307+
* This is an operation method for {@see Type::acceptValue()}.
308308
*
309309
* Default implementation expects the value class to reside in the same namespace as its
310310
* FieldType class and is named "Value".
311311
*
312312
* Example implementation:
313-
* <code>
313+
* ```
314314
* protected function checkValueType($value): void
315315
* {
316-
* if ( !$inputValue instanceof \My\FieldType\CookieJar\Value ) )
316+
* if (!$inputValue instanceof \My\FieldType\CookieJar\Value))
317317
* {
318-
* throw new InvalidArgumentException( "Given value type is not supported." );
318+
* throw new InvalidArgumentException("Given value type isn't supported.");
319319
* }
320320
* }
321-
* </code>
321+
* ```
322322
*
323-
* @param mixed $value A value returned by {@see createValueFromInput()}.
323+
* @param mixed $value A value returned by {@see Type::createValueFromInput()}.
324324
*
325325
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException If the parameter is not an instance of the supported value subtype.
326326
*/

src/contracts/FieldType/Generic/ValidationError/ConstraintViolationAdapter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
use Symfony\Component\Validator\ConstraintViolationInterface;
1515

1616
/**
17-
* {@see \Symfony\Component\Validator\ConstraintViolationInterface} to
18-
* {@see \Ibexa\Contracts\Core\FieldType\ValidationError} adapter.
17+
* Constraint violation validation error.
18+
*
19+
* Adapts {@see \Symfony\Component\Validator\ConstraintViolationInterface} to
20+
* {@see \Ibexa\Contracts\Core\FieldType\ValidationError}.
1921
*/
2022
final class ConstraintViolationAdapter implements ValidationErrorInterface
2123
{

0 commit comments

Comments
 (0)