Skip to content

Commit d10c56d

Browse files
committed
Merge branch 'release/5.0.0-rc.1'
2 parents 903d339 + 99fa0f2 commit d10c56d

17 files changed

Lines changed: 181 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. This projec
55

66
## Unreleased
77

8+
## [5.0.0-rc.1] - 2025-10-09
9+
10+
### Added
11+
12+
- **BREAKING**: The `Identifier` interface now has an `any()` method that returns `true` if any of the given identifiers
13+
match the identifier. If you have implemented any custom identifiers, you can add the `IsIdentifier` trait to
14+
implement this new method.
15+
- **BREAKING**: Add `message()` and `messages()` helper methods to the `ErrorList` interface. Although technically
16+
breaking, this will not affect most implementations as the concrete error list class provided this package has been
17+
updated.
18+
819
## [4.1.0] - 2025-10-03
920

1021
### Added
@@ -489,6 +500,10 @@ All notable changes to this project will be documented in this file. This projec
489500

490501
Initial release.
491502

503+
[5.0.0-rc.1]: https://github.com/cloudcreativity/ddd-modules/compare/v4.1.0...v5.0.0-rc.1
504+
505+
[4.1.0]: https://github.com/cloudcreativity/ddd-modules/compare/v4.0.0...v4.1.0
506+
492507
[4.0.0]: https://github.com/cloudcreativity/ddd-modules/compare/v3.4.0...v4.0.0
493508

494509
[3.4.0]: https://github.com/cloudcreativity/ddd-modules/compare/v3.3.1...v3.4.0

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
},
6262
"extra": {
6363
"branch-alias": {
64-
"dev-develop": "4.x-dev",
65-
"dev-next": "5.x-dev"
64+
"dev-develop": "5.x-dev",
65+
"dev-next": "6.x-dev"
6666
}
6767
},
6868
"minimum-stability": "stable",

docs/guide/upgrade.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Upgrade Guide
22

3+
## 4.x to 5.x
4+
5+
Upgrade using Composer:
6+
7+
```bash
8+
composer config minimum-stability rc
9+
composer require cloudcreativity/ddd-modules:^5.0
10+
```
11+
12+
### Identifiers
13+
14+
A new `any()` method has been added to the `Identifier` interface. This will only affect your implementation if you have
15+
implemented any custom identifier classes. To solve, add the `IsIdentifier` trait to your class.
16+
17+
### Other Changes
18+
19+
Although this release contains other breaking changes, most implementations can upgrade without making any changes. This
20+
is because the majority of changes affect classes that are implemented by this package - and it is unlikely you are
21+
implementing these yourself.
22+
23+
Refer to the changelog for a full list of changes.
24+
325
## 3.x to 4.x
426

527
Upgrade using Composer:
@@ -8,7 +30,9 @@ Upgrade using Composer:
830
composer require cloudcreativity/ddd-modules:^4.0
931
```
1032

11-
Although this release contains breaking changes, most implementations can upgrade without making any changes. This is because the majority of changes affect classes that are implemented by this package - and it is unlikely you are implementing these yourself.
33+
Although this release contains breaking changes, most implementations can upgrade without making any changes. This is
34+
because the majority of changes affect classes that are implemented by this package - and it is unlikely you are
35+
implementing these yourself.
1236

1337
Refer to the changelog for a full list of changes.
1438

src/Contracts/Toolkit/Identifiers/Identifier.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ interface Identifier extends Stringable, Contextual
2222
*/
2323
public function is(?self $other): bool;
2424

25+
/**
26+
* Is the identifier any of the provided identifiers?
27+
*/
28+
public function any(?self ...$others): bool;
29+
2530
/**
2631
* Fluent to-string method.
2732
*/

src/Contracts/Toolkit/Result/ListOfErrors.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function contains(Closure|UnitEnum $matcher): bool;
3838
/**
3939
* Get all the unique error codes in the list.
4040
*
41-
* @return array<UnitEnum>
41+
* @return list<UnitEnum>
4242
*/
4343
public function codes(): array;
4444

@@ -47,6 +47,20 @@ public function codes(): array;
4747
*/
4848
public function code(): ?UnitEnum;
4949

50+
/**
51+
* Get all the unique error messages in the list.
52+
*
53+
* @return list<non-empty-string>
54+
*/
55+
public function messages(): array;
56+
57+
/**
58+
* Get the first error message in the list.
59+
*
60+
* @return non-empty-string|null
61+
*/
62+
public function message(): ?string;
63+
5064
/**
5165
* Return a new instance with the provided error pushed on to the end of the list.
5266
*

src/Toolkit/Identifiers/Guid.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
final readonly class Guid implements Identifier
2525
{
26+
use IsIdentifier;
27+
2628
public static function from(Identifier $value): self
2729
{
2830
if ($value instanceof self) {

src/Toolkit/Identifiers/IntegerId.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
final readonly class IntegerId implements Identifier, JsonSerializable
2121
{
22+
use IsIdentifier;
23+
2224
public static function from(Identifier|int $value): self
2325
{
2426
return match(true) {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2025 Cloud Creativity Limited
5+
*
6+
* Use of this source code is governed by an MIT-style
7+
* license that can be found in the LICENSE file or at
8+
* https://opensource.org/licenses/MIT.
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
namespace CloudCreativity\Modules\Toolkit\Identifiers;
14+
15+
use CloudCreativity\Modules\Contracts\Toolkit\Identifiers\Identifier;
16+
17+
trait IsIdentifier
18+
{
19+
public function any(?Identifier ...$others): bool
20+
{
21+
return array_any(
22+
$others,
23+
fn (?Identifier $other): bool => $this->is($other),
24+
);
25+
}
26+
}

src/Toolkit/Identifiers/StringId.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
final readonly class StringId implements Identifier, JsonSerializable
2121
{
22+
use IsIdentifier;
23+
2224
public static function from(Identifier|string $value): self
2325
{
2426
return match(true) {

src/Toolkit/Identifiers/Uuid.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
final class Uuid implements Identifier, JsonSerializable
2222
{
23+
use IsIdentifier;
24+
2325
private static ?IUuidFactory $factory = null;
2426

2527
public static function setFactory(?IUuidFactory $factory): void

0 commit comments

Comments
 (0)