Skip to content

Commit 92ea570

Browse files
committed
Merge branch 'develop'
* develop: specify next release discard psalm error add SideEffect::identity() bump minimum version of blackbox Revert "try forcing the use of blackbox 5" try forcing the use of blackbox 5 Revert "try forcing the use of blackbox 6" try forcing the use of blackbox 6 add support for blackbox 6
2 parents 23d3bb0 + 5fa9cad commit 92ea570

11 files changed

Lines changed: 77 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 5.12.0 - 2025-03-19
4+
5+
### Added
6+
7+
- Support for `innmind/black-box` `6`
8+
- `Innmind\Immutable\SideEffect::identity()`
9+
10+
### Deprecated
11+
12+
- `Innmind\Immutable\SideEffect::__construct()`, use `Innmind\Immutable\SideEffect::identity()` instead
13+
314
## 5.11.3 - 2025-02-26
415

516
### Changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
},
3232
"require-dev": {
3333
"innmind/static-analysis": "^1.2.1",
34-
"innmind/black-box": "^5.5.1",
34+
"innmind/black-box": "^5.5.1|^6.0.1",
3535
"innmind/coding-standard": "~2.0"
3636
},
3737
"conflict": {
38-
"innmind/black-box": "<5.0|~6.0"
38+
"innmind/black-box": "<5.0|~7.0"
3939
},
4040
"suggest": {
4141
"innmind/black-box": "For property based testing"
4242
},
4343
"provide": {
44-
"innmind/black-box-sets": "5.0"
44+
"innmind/black-box-sets": "5.0|6.0"
4545
}
4646
}

fixtures/Sequence.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,27 @@ final class Sequence
1515
* @template I
1616
*
1717
* @param Set<I> $set
18+
* @param Set<int> $sizes
1819
*
1920
* @return Set<Structure<I>>
2021
*/
21-
public static function of(Set $set, ?Set\Integers $sizes = null): Set
22+
public static function of(Set $set, ?Set $sizes = null): Set
2223
{
24+
if (\interface_exists(Set\Implementation::class)) {
25+
$sizes ??= Set::integers()->between(0, 100);
26+
27+
return Set::compose(
28+
static fn($min, $max) => Set::sequence($set)
29+
->between(
30+
\min($min, $max),
31+
\max($min, $max),
32+
)
33+
->map(static fn(array $values): Structure => Structure::of(...$values)),
34+
$sizes,
35+
$sizes,
36+
)->flatMap(static fn($sequences) => $sequences->unwrap());
37+
}
38+
2339
// this is not optimal but it allows to avoid a BC break
2440
$sizes ??= Set\Integers::between(0, 100);
2541
$range = [

fixtures/Set.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,32 @@ final class Set
1717
/**
1818
* @template I
1919
*
20-
* @param Set<I> $set
20+
* @param DataSet<I> $set
21+
* @param DataSet<int> $sizes
2122
*
22-
* @return Set<Structure<I>>
23+
* @return DataSet<Structure<I>>
2324
*/
24-
public static function of(DataSet $set, ?DataSet\Integers $sizes = null): DataSet
25+
public static function of(DataSet $set, ?DataSet $sizes = null): DataSet
2526
{
27+
if (\interface_exists(DataSet\Implementation::class)) {
28+
$sizes ??= DataSet::integers()->between(0, 100);
29+
30+
return DataSet::compose(
31+
static fn($min, $max) => DataSet::sequence($set)
32+
->between(
33+
\min($min, $max),
34+
\max($min, $max),
35+
)
36+
->filter(static function(array $values): bool {
37+
// checks unicity of values
38+
return ISequence::mixed(...$values)->size() === Structure::mixed(...$values)->size();
39+
})
40+
->map(static fn(array $values): Structure => Structure::of(...$values)),
41+
$sizes,
42+
$sizes,
43+
)->flatMap(static fn($sequences) => $sequences->unwrap());
44+
}
45+
2646
// this is not optimal but it allows to avoid a BC break
2747
$sizes ??= DataSet\Integers::between(0, 100);
2848
$range = [

src/Map/ObjectKeys.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function foreach(callable $function): SideEffect
214214
$function($key, $v);
215215
}
216216

217-
return new SideEffect;
217+
return SideEffect::identity();
218218
}
219219

220220
/**

src/Map/Primitive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function foreach(callable $function): SideEffect
192192
$function($k, $v);
193193
}
194194

195-
return new SideEffect;
195+
return SideEffect::identity();
196196
}
197197

198198
/**

src/Map/Uninitialized.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function filter(callable $predicate): self
119119
#[\Override]
120120
public function foreach(callable $function): SideEffect
121121
{
122-
return new SideEffect;
122+
return SideEffect::identity();
123123
}
124124

125125
/**

src/Sequence/Defer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function foreach(callable $function): SideEffect
282282
$this->values->next();
283283
}
284284

285-
return new SideEffect;
285+
return SideEffect::identity();
286286
}
287287

288288
/**

src/Sequence/Lazy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public function foreach(callable $function): SideEffect
270270
$iterator->next();
271271
}
272272

273-
return new SideEffect;
273+
return SideEffect::identity();
274274
}
275275

276276
/**

src/Sequence/Primitive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function foreach(callable $function): SideEffect
178178
$function($value);
179179
}
180180

181-
return new SideEffect;
181+
return SideEffect::identity();
182182
}
183183

184184
/**

0 commit comments

Comments
 (0)