Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 0 additions & 126 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5088,12 +5088,6 @@ parameters:
count: 1
path: src/contracts/Limitation/Target/Builder/VersionBuilder.php

-
message: '#^Method Ibexa\\Contracts\\Core\\Limitation\\Type\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/contracts/Limitation/Type.php

-
message: '#^Method Ibexa\\Contracts\\Core\\MVC\\Templating\\BaseRenderStrategy\:\:__construct\(\) has parameter \$fragmentRenderers with no value type specified in iterable type iterable\.$#'
identifier: missingType.iterableValue
Expand Down Expand Up @@ -10536,30 +10530,12 @@ parameters:
count: 1
path: src/lib/IO/UrlDecorator/Prefix.php

-
message: '#^Method Ibexa\\Core\\Limitation\\BlockingLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/BlockingLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\BlockingLimitationType\:\:evaluate\(\) has Ibexa\\Contracts\\Core\\Repository\\Exceptions\\BadStateException in PHPDoc @throws tag but it''s not thrown\.$#'
identifier: throws.unusedType
count: 1
path: src/lib/Limitation/BlockingLimitationType.php

-
message: '#^Return type \(void\) of method Ibexa\\Core\\Limitation\\ChangeOwnerLimitationType\:\:valueSchema\(\) should be compatible with return type \(array\<mixed\>\|int\) of method Ibexa\\Contracts\\Core\\Limitation\\Type\:\:valueSchema\(\)$#'
identifier: method.childReturnType
count: 1
path: src/lib/Limitation/ChangeOwnerLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ContentTypeLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/ContentTypeLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\LanguageLimitation\\ContentDeleteEvaluator\:\:evaluate\(\) never returns null so it can be removed from the return type\.$#'
identifier: return.unusedType
Expand Down Expand Up @@ -10596,12 +10572,6 @@ parameters:
count: 1
path: src/lib/Limitation/LanguageLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\LanguageLimitationType\:\:valueSchema\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/Limitation/LanguageLimitationType.php

-
message: '#^Parameter \#1 \$array of function array_keys expects array, iterable\<Ibexa\\Contracts\\Core\\Persistence\\Content\\Language\> given\.$#'
identifier: argument.type
Expand All @@ -10614,12 +10584,6 @@ parameters:
count: 1
path: src/lib/Limitation/LanguageLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\LocationLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/LocationLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\LocationLimitationType\:\:evaluateForContentCreateStruct\(\) has parameter \$targets with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand All @@ -10644,18 +10608,6 @@ parameters:
count: 1
path: src/lib/Limitation/MemberOfLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\NewObjectStateLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/NewObjectStateLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\NewSectionLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/NewSectionLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\NewSectionLimitationType\:\:doEvaluate\(\) has parameter \$targets with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand All @@ -10680,12 +10632,6 @@ parameters:
count: 1
path: src/lib/Limitation/NewSectionLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ObjectStateLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/ObjectStateLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ObjectStateLimitationType\:\:getObjectStateIdsToVerify\(\) has parameter \$limitationValues with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand All @@ -10704,84 +10650,18 @@ parameters:
count: 1
path: src/lib/Limitation/ObjectStateLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\OwnerLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/OwnerLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ParentContentTypeLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/ParentContentTypeLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ParentContentTypeLimitationType\:\:evaluateForContentCreateStruct\(\) has parameter \$targets with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/Limitation/ParentContentTypeLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ParentDepthLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/ParentDepthLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ParentDepthLimitationType\:\:evaluateForContentCreateStruct\(\) has parameter \$targets with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/Limitation/ParentDepthLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ParentOwnerLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/ParentOwnerLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\ParentUserGroupLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/ParentUserGroupLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\SectionLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/SectionLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\SectionLimitationType\:\:evaluate\(\) should return bool but returns null\.$#'
identifier: return.type
count: 1
path: src/lib/Limitation/SectionLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\SiteAccessLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/SiteAccessLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\StatusLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/StatusLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\SubtreeLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/SubtreeLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\SubtreeLimitationType\:\:evaluate\(\) should return bool but returns null\.$#'
identifier: return.type
count: 2
path: src/lib/Limitation/SubtreeLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\SubtreeLimitationType\:\:evaluateForContentCreateStruct\(\) has parameter \$targets with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand All @@ -10800,12 +10680,6 @@ parameters:
count: 1
path: src/lib/Limitation/TargetOnlyLimitationType.php

-
message: '#^Method Ibexa\\Core\\Limitation\\UserGroupLimitationType\:\:acceptValue\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Limitation/UserGroupLimitationType.php

-
message: '#^PHPDoc tag @var does not specify variable name\.$#'
identifier: varTag.noVariable
Expand Down
16 changes: 7 additions & 9 deletions src/contracts/Limitation/Target/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,33 @@ final class Version extends ValueObject implements Target
*
* @var string[]
*/
protected $allLanguageCodesList = [];
protected array $allLanguageCodesList = [];

/**
* List of content types. At least one must match Limitation values.
*
* @var int[]
*/
protected $allContentTypeIdsList = [];
protected array $allContentTypeIdsList = [];

/**
* Language code of a translation used when updated, can be null for e.g. multiple translations changed.
*
* @var string|null
*/
protected $forUpdateInitialLanguageCode;
protected ?string $forUpdateInitialLanguageCode = null;

/**
* List of language codes of translations to update. All must match Limitation values.
*
* @var string[]
*/
protected $forUpdateLanguageCodesList = [];
protected array $forUpdateLanguageCodesList = [];

/**
* List of language codes of translations to publish. All must match Limitation values.
*
* @var string[]
*/
protected $forPublishLanguageCodesList = [];
protected array $forPublishLanguageCodesList = [];

/**
* One of the following: STATUS_DRAFT, STATUS_PUBLISHED, STATUS_ARCHIVED.
Expand All @@ -68,10 +66,10 @@ final class Version extends ValueObject implements Target
*
* @var int|null
*/
protected $newStatus;
protected ?int $newStatus = null;

/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Field[] */
protected $updatedFields = [];
protected array $updatedFields = [];

/**
* List of language codes of translations to delete. All must match Limitation values.
Expand Down
34 changes: 15 additions & 19 deletions src/contracts/Limitation/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Contracts\Core\Limitation;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Core\Repository\Values\User\Limitation as APILimitationValue;
use Ibexa\Contracts\Core\Repository\Values\User\UserReference as APIUserReference;
use Ibexa\Contracts\Core\Repository\Values\ValueObject as APIValueObject;
Expand All @@ -28,7 +30,7 @@ interface Type
*
* Note: In future version constant values might change to 1, 0 and -1 as used in Symfony.
*/
public const ACCESS_GRANTED = true;
public const ?bool ACCESS_GRANTED = true;

/**
* The type abstains from voting.
Expand All @@ -40,7 +42,7 @@ interface Type
*
* Note: In future version constant values might change to 1, 0 and -1 as used in Symfony.
*/
public const ACCESS_ABSTAIN = null;
public const ?bool ACCESS_ABSTAIN = null;

/**
* Access is denied.
Expand All @@ -49,7 +51,7 @@ interface Type
*
* Note: In future version constant values might change to 1, 0 and -1 as used in Symfony.
*/
public const ACCESS_DENIED = false;
public const ?bool ACCESS_DENIED = false;

/**
* Limitation's value must be an array of location IDs.
Expand All @@ -58,7 +60,7 @@ interface Type
*
* GUI should typically present option to browse content tree to select limitation value(s).
*/
public const VALUE_SCHEMA_LOCATION_ID = 1;
public const int VALUE_SCHEMA_LOCATION_ID = 1;

/**
* Limitation's value must be an array of location paths.
Expand All @@ -67,7 +69,7 @@ interface Type
*
* GUI should typically present option to browse content tree to select limitation value(s).
*/
public const VALUE_SCHEMA_LOCATION_PATH = 2;
public const int VALUE_SCHEMA_LOCATION_PATH = 2;

/**
* Accepts a Limitation value and checks for structural validity.
Expand All @@ -78,7 +80,7 @@ interface Type
*
* @param \Ibexa\Contracts\Core\Repository\Values\User\Limitation $limitationValue
*/
public function acceptValue(APILimitationValue $limitationValue);
public function acceptValue(APILimitationValue $limitationValue): void;

/**
* Makes sure LimitationValue->limitationValues is valid according to valueSchema().
Expand All @@ -89,7 +91,7 @@ public function acceptValue(APILimitationValue $limitationValue);
*
* @return array<int, \Ibexa\Contracts\Core\FieldType\ValidationError>
*/
public function validate(APILimitationValue $limitationValue);
public function validate(APILimitationValue $limitationValue): array;

/**
* Create the Limitation Value.
Expand All @@ -101,17 +103,11 @@ public function validate(APILimitationValue $limitationValue);
*
* @return \Ibexa\Contracts\Core\Repository\Values\User\Limitation
*/
public function buildValue(array $limitationValues);
public function buildValue(array $limitationValues): APILimitationValue;

/**
* Evaluate ("Vote") against a main value object and targets for the context.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException If any of the arguments are invalid
* Example: If LimitationValue is instance of ContentTypeLimitationValue, and Type is SectionLimitationType.
* However if $object or $targets is unsupported by ROLE limitation, ACCESS_ABSTAIN should be returned!
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException If value of the LimitationValue is unsupported
* Example if OwnerLimitationValue->limitationValues[0] is not one of: [ 1, 2 ]
*
* @param \Ibexa\Contracts\Core\Repository\Values\User\Limitation $value
* @param \Ibexa\Contracts\Core\Repository\Values\User\UserReference $currentUser
* @param \Ibexa\Contracts\Core\Repository\Values\ValueObject $object
Expand All @@ -120,7 +116,7 @@ public function buildValue(array $limitationValues);
*
* @return bool|null Returns one of ACCESS_* constants, {@see Type::ACCESS_GRANTED}, {@see Type::ACCESS_ABSTAIN}, or {@see Type::ACCESS_DENIED}.
*/
public function evaluate(APILimitationValue $value, APIUserReference $currentUser, APIValueObject $object, array $targets = null);
public function evaluate(APILimitationValue $value, APIUserReference $currentUser, APIValueObject $object, array $targets = null): ?bool;

/**
* Returns Criterion for use in find() query.
Expand All @@ -131,16 +127,16 @@ public function evaluate(APILimitationValue $value, APIUserReference $currentUse
* @param \Ibexa\Contracts\Core\Repository\Values\User\Limitation $value
* @param \Ibexa\Contracts\Core\Repository\Values\User\UserReference $currentUser
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface|\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalOperator
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface
*/
public function getCriterion(APILimitationValue $value, APIUserReference $currentUser);
public function getCriterion(APILimitationValue $value, APIUserReference $currentUser): CriterionInterface;

/**
* Returns info on valid $limitationValues.
*
* @return mixed[]|int In case of array, a hash with key as valid limitations value and value as human readable name
* @return int|mixed[] In case of array, a hash with key as valid limitations value and value as human readable name
* of that option, in case of int on of VALUE_SCHEMA_* constants.
* Note: The hash might be an instance of Traversable, and not a native php array.
*/
public function valueSchema();
public function valueSchema(): array|int;
}
Loading
Loading