Skip to content

Commit

Permalink
Rework read only
Browse files Browse the repository at this point in the history
  • Loading branch information
steevanb committed May 15, 2024
1 parent 781d78a commit 0d04b41
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 69 deletions.
133 changes: 67 additions & 66 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@
- Add support for PHP `8.3`
- Update CI dependencies
- Add support for generics
- [BC break] Remove `ObjectCollectionDenormalizer::createObjectCollection()` and `add()`
- [BC break] Rename ObjectCollectionDenormalizer::denormalizeObject()` to `denormalizeValue()`
- [BC break] Remove `ScalarCollectionInterface`
- [BC break] Remove `ScalarCollectionDenormalizer::createScalarCollection()`
- **[BC break]** Remove `ObjectCollectionDenormalizer::createObjectCollection()` and `add()`
- **[BC break]** Rename ObjectCollectionDenormalizer::denormalizeObject()` to `denormalizeValue()`
- **[BC break]** Remove `ScalarCollectionInterface`
- **[BC break]** Remove `ScalarCollectionDenormalizer::createScalarCollection()`
- Add `bridge/` to phpstan
- Add generics everywhere it's possible
- [BC break] Remove `FloatCollectionInterface` and `FloatNullableCollectionInterface`
- [BC break] Remove `IntegerCollectionInterface` and `IntegerNullableCollectionInterface`
- [BC break] Remove `StringCollectionInterface` and `StringNullableCollectionInterface`
- [BC break] `AbstractCollection::getStringKeys()` return `StringCollection` instead of `StringCollectionInterface`
- [BC break] `AbstractCollection::getIntegerKeys()` return `IntegerCollection` instead of `IntegerCollectionInterface`
- [BC break] Rename AbstractCollection::`doReplace()` to `replace()`
- [BC break] Rename AbstractCollection::`doGet()` to `get()`
- [BC break] Rename AbstractCollection::`doHas()` to `contains()`
- [BC break] Add `CollectionInterface::__construct()`
- [BC break] Change return type of `CollectionInterface::getIntegerKeys()` from `IntegerCollectionInterface` to `IntegerCollection`
- [BC break] Change return type of `CollectionInterface::getStringKeys()` from `StringCollectionInterface` to `StringCollection`
- [BC break] Add `CollectionInterface::get()`
- [BC break] Add `CollectionInterface::contains()`
- [BC break] Add `CollectionInterface::replace()`
- [BC break] Remove `AbstractEnumCollection`, use `AbstractObjectCollection` instead
- [BC break] Add `AbstractObjectCollection::getValueFqcn()`
- [BC break] Add parameter `$value` to `AbstractObjectCollection::getAssertInstanceOfError()`
- [BC break] Add `AbstractObjectNullableCollection::getValueFqcn()`
- [BC break] Add parameter `$value` to `AbstractObjectNullableCollection::getAssertInstanceOfError()`
- [BC break] Add parameter `$value` to `ObjectCollectionTrait::getAssertInstanceOfError()`
- [BC break] Remove `ObjectCollectionTrait::assertClassName()`
- **[BC break]** Remove `FloatCollectionInterface` and `FloatNullableCollectionInterface`
- **[BC break]** Remove `IntegerCollectionInterface` and `IntegerNullableCollectionInterface`
- **[BC break]** Remove `StringCollectionInterface` and `StringNullableCollectionInterface`
- **[BC break]** `AbstractCollection::getStringKeys()` return `StringCollection` instead of `StringCollectionInterface`
- **[BC break]** `AbstractCollection::getIntegerKeys()` return `IntegerCollection` instead of `IntegerCollectionInterface`
- **[BC break]** Rename AbstractCollection::`doReplace()` to `replace()`
- **[BC break]** Rename AbstractCollection::`doGet()` to `get()`
- **[BC break]** Rename AbstractCollection::`doHas()` to `contains()`
- **[BC break]** Add `CollectionInterface::__construct()`
- **[BC break]** Change return type of `CollectionInterface::getIntegerKeys()` from `IntegerCollectionInterface` to `IntegerCollection`
- **[BC break]** Change return type of `CollectionInterface::getStringKeys()` from `StringCollectionInterface` to `StringCollection`
- **[BC break]** Add `CollectionInterface::get()`
- **[BC break]** Add `CollectionInterface::contains()`
- **[BC break]** Add `CollectionInterface::replace()`
- **[BC break]** Remove `AbstractEnumCollection`, use `AbstractObjectCollection` instead
- **[BC break]** Add `AbstractObjectCollection::getValueFqcn()`
- **[BC break]** Add parameter `$value` to `AbstractObjectCollection::getAssertInstanceOfError()`
- **[BC break]** Add `AbstractObjectNullableCollection::getValueFqcn()`
- **[BC break]** Add parameter `$value` to `AbstractObjectNullableCollection::getAssertInstanceOfError()`
- **[BC break]** Add parameter `$value` to `ObjectCollectionTrait::getAssertInstanceOfError()`
- **[BC break]** Remove `ObjectCollectionTrait::assertClassName()`
- `ObjectCollectionTrait::castValueToString()` can cast the value from `\BackedEnum` and `\UnitEnum`
- Because of generics, remove methods in `FloatCollection`: `__construct()`, `replace()`, `has()`, `get()`, `merge()` and `toArray()`
- Because of generics, remove methods in `FloatNullableCollection`: `__construct()`, `replace()`, `has()`, `get()`, `merge()` and `toArray()`
Expand All @@ -39,57 +39,58 @@
- Because of generics, remove methods in `StringCollection`: `__construct()`, `replace()`, `has()`, `get()`, `merge()` and `toArray()`
- Because of generics, remove methods in `StringNullableCollection`: `__construct()`, `replace()`, `has()`, `get()`, `merge()` and `toArray()`
- [Edhrendal](https://github.com/Edhrendal) Add `AbstractCollection::isEmpty()`
- [BC break] Add `CollectionInterface::isEmpty()`
- **[BC break]** Add `CollectionInterface::isEmpty()`
- Remove `CollectionInterface::getIntegerKeys()` and `CollectionInterface::getStringKeys()`. It still exists in `AbstractCollection`.
- **[BC break]** Remove parameter `$readOnly` in `CollectionInterface::setReadOnly()`

### [5.0.1](../../compare/5.0.0...5.0.1) - 2023-03-14

- Fix `AbstractCollection::doAdd()` who was not calling `canAddValue()`

### [5.0.0](../../compare/4.0.0...5.0.0) - 2023-03-14

- [BC break] Rename repository, namespace and everything else from `TypedArray` to `Collection`
- **[BC break]** Rename repository, namespace and everything else from `TypedArray` to `Collection`
- Define PHP `8.1` as default PHP version in Docker image `steevanb/php-typed-array:ci`
- Update Composer to `2.5.4`
- [BC break] Remove `AbstractTypedArray::$nullValueMode`
- **[BC break]** Remove `AbstractTypedArray::$nullValueMode`
- Call `$this->clear()` in `AbstractTypedArray::setValues()`
- Rework `AbstractTypedArray::changeKeyCase()`
- [BC break] Remove `NullValueException`
- [BC break] Remove `NullValueModeEnum`
- **[BC break]** Remove `NullValueException`
- **[BC break]** Remove `NullValueModeEnum`
- Add PHPDoc everywhere to force return types in `toArray()`
- [BC break] Remove `AbstractScalarArray`
- **[BC break]** Remove `AbstractScalarArray`
- Add `ScalarArrayInterface` for `ScalarArrayDenormalizer`
- [BC break] Remove `ScalarArray`: it was not enough typed, too much types can be added
- [BC break] `FloatArray`, `IntArray` and `StringArray` now accepts only the right type (null is not allowed too), values will not be casted by the TypedArray
- [BC break] Remove `ByteStringArray`, `CodePointStringArray` and `UnicodeStringArray`: they are specific to another library
- **[BC break]** Remove `ScalarArray`: it was not enough typed, too much types can be added
- **[BC break]** `FloatArray`, `IntArray` and `StringArray` now accepts only the right type (null is not allowed too), values will not be casted by the TypedArray
- **[BC break]** Remove `ByteStringArray`, `CodePointStringArray` and `UnicodeStringArray`: they are specific to another library
- Add `FloatNullableArray`, `IntNullableArray`, `StringNullableArray` and `ObjectNullableArray` who allow `null` and the right type
- [BC break] Remove `setValueAlreadyExistMode()`, now it's a parameter in `__construct()`
- [BC break] Change `__construct()` parameters for all TypedArray classes
- [BC break] AbstractEnumArray new extends `AbstractTypedArray` and not `ObjectArray`
- [BC break] Rename `Steevanb\PhpTypedArray\ObjectComparisonModeEnum` to `Steevanb\PhpTypedArray\ObjectArray\ComparisonModeEnum`
- [BC break] Remove `ObjectArray` to force an `ObjectArray` to have instance of only one class/interface.
- [BC break] Default comparison mode for `ObjectArray` is `HASH` (it was `STRING`)
- [BC break] Rename `ValueAlreadyExistException` to `ValueAlreadyExistsException` and `AbstractTypedArray::getValueAlreadyExistMode()` to `AbstractTypedArray::getValueAlreadyExistsMode()`
- [BC break] Remove parameter `$offset` of `AbstractTypedArray::canAddValue()`
- [BC break] Rename `IntCollection` to `IntegerCollection`
- [BC break] Remove implementations of `\Iterator` and `\ArrayAccess`, too much bugs in PHP with this interfaces
- [BC break] Remove phpstan rule
- [BC break] `AbstractCollection::changeKeyCase()` parameter `$case` type changed from `int` to `KeyCaseEnum`
- **[BC break]** Remove `setValueAlreadyExistMode()`, now it's a parameter in `__construct()`
- **[BC break]** Change `__construct()` parameters for all TypedArray classes
- **[BC break]** AbstractEnumArray new extends `AbstractTypedArray` and not `ObjectArray`
- **[BC break]** Rename `Steevanb\PhpTypedArray\ObjectComparisonModeEnum` to `Steevanb\PhpTypedArray\ObjectArray\ComparisonModeEnum`
- **[BC break]** Remove `ObjectArray` to force an `ObjectArray` to have instance of only one class/interface.
- **[BC break]** Default comparison mode for `ObjectArray` is `HASH` (it was `STRING`)
- **[BC break]** Rename `ValueAlreadyExistException` to `ValueAlreadyExistsException` and `AbstractTypedArray::getValueAlreadyExistMode()` to `AbstractTypedArray::getValueAlreadyExistsMode()`
- **[BC break]** Remove parameter `$offset` of `AbstractTypedArray::canAddValue()`
- **[BC break]** Rename `IntCollection` to `IntegerCollection`
- **[BC break]** Remove implementations of `\Iterator` and `\ArrayAccess`, too much bugs in PHP with this interfaces
- **[BC break]** Remove phpstan rule
- **[BC break]** `AbstractCollection::changeKeyCase()` parameter `$case` type changed from `int` to `KeyCaseEnum`

### [4.0.0](../../compare/3.3.2...4.0.0) - 2022-12-20

- [BC break] Remove support for PHP 7.1, 7.2, 7.3, 7.4 and 8.0
- **[BC break]** Remove support for PHP 7.1, 7.2, 7.3, 7.4 and 8.0
- Add support for PHP 8.2
- [BC break] Remove support for Symfony < 6.1
- **[BC break]** Remove support for Symfony < 6.1
- Add support for Symfony 6.1 and 6.2
- [BC break] Rename namespace first part from `steevanb` to `Steevanb`
- [BC break] `AbstractTypedArray::NULL_VALUE_ALLOW`, `NULL_VALUE_DO_NOT_ADD` and `NULL_VALUE_EXCEPTION` are replaced by `NullValueModeEnum`
- [BC break] `AbstractTypedArray::VALUE_ALREADY_EXIST_ADD`, `VALUE_ALREADY_EXIST_DO_NOT_ADD` and `VALUE_ALREADY_EXIST_EXCEPTION` are replaced by `ValueAlreadyExistsModeEnum`
- [BC break] `ObjectArray::COMPARISON_STRING` and `COMPARISON_OBJECT_HASH` are replaced by `ObjectComparisonModeEnum`
- [BC break] Add types everywhere we can
- **[BC break]** Rename namespace first part from `steevanb` to `Steevanb`
- **[BC break]** `AbstractTypedArray::NULL_VALUE_ALLOW`, `NULL_VALUE_DO_NOT_ADD` and `NULL_VALUE_EXCEPTION` are replaced by `NullValueModeEnum`
- **[BC break]** `AbstractTypedArray::VALUE_ALREADY_EXIST_ADD`, `VALUE_ALREADY_EXIST_DO_NOT_ADD` and `VALUE_ALREADY_EXIST_EXCEPTION` are replaced by `ValueAlreadyExistsModeEnum`
- **[BC break]** `ObjectArray::COMPARISON_STRING` and `COMPARISON_OBJECT_HASH` are replaced by `ObjectComparisonModeEnum`
- **[BC break]** Add types everywhere we can
- Add `AbstractEnumArray` to store PHP 8.1 `\UnitEnum`.
- [BC break] `ObjectArray` could not store instances of `\UnitEnum` anymore.
- [BC break] Remove ReadOnlyInterface, merged into CollectionInterface
- **[BC break]** `ObjectArray` could not store instances of `\UnitEnum` anymore.
- **[BC break]** Remove ReadOnlyInterface, merged into CollectionInterface

### [3.3.2](../../compare/3.3.1...3.3.2) - 2021-12-23

Expand Down Expand Up @@ -121,7 +122,7 @@
### [3.1.0](../../compare/3.0.1...3.1.0) - 2021-05-10

- Allow PHP `^8.0` (it was already compatible)
- [BC break] Removed `steevanb\PhpTypedArray\ScalarArray\BoolArray`: do not work and will never work due to `\Iterator`
- **[BC break]** Removed `steevanb\PhpTypedArray\ScalarArray\BoolArray`: do not work and will never work due to `\Iterator`

### [3.0.1](../../compare/3.0.0...3.0.1) - 2021-02-18

Expand All @@ -131,17 +132,17 @@
### [3.0.0](../../compare/2.6.0...3.0.0) - 2021-02-18

- Add tests for [symfony/serializer](https://github.com/symfony/serializer) `4.4`, `5.0`, `5.1` and `5.2`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\AbstractObjectArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\ByteStringArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\CodePointStringArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\UnicodeStringArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\AbstractObjectArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\ByteStringArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\CodePointStringArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\UnicodeStringArrayDenormalizer`
- Moved `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArray\ObjectArrayDenormalizer` to `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ObjectArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\AbstractScalarArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\BoolArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\FloatArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\IntArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\ScalarArrayDenormalizer`
- [BC break] Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\StringArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\AbstractScalarArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\BoolArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\FloatArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\IntArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\ScalarArrayDenormalizer`
- **[BC break]** Removed `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\StringArrayDenormalizer`
- Add `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArrayDenormalizer` to replace `steevanb\PhpTypedArray\Bridge\Symfony\Normalizer\ScalarArray\*Denormalizer`
- Create Docker image `steevanb/php-typed-array-ci:1.0.0` who contains [symfony/serializer](https://github.com/symfony/serializer) versions and [phpstan](https://github.com/phpstan/phpstan)

Expand Down
4 changes: 2 additions & 2 deletions src/AbstractCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function isEmpty(): bool
return $this->count() === 0;
}

public function setReadOnly(bool $readOnly = true): static
public function setReadOnly(): static
{
$this->readOnly = $readOnly;
$this->readOnly = true;

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getKeys(): array;

public function hasKey(string|int $key): bool;

public function setReadOnly(bool $readOnly): static;
public function setReadOnly(): static;

public function isReadOnly(): bool;

Expand Down

0 comments on commit 0d04b41

Please sign in to comment.