Skip to content

Commit 9fb2c1f

Browse files
committed
Updated README and added some '@see' marker for deprecated methods
1 parent 6bc7029 commit 9fb2c1f

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

README.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class User
187187
}
188188
```
189189

190-
* Makes sure the resulting enumerator exactly matches an enumeration. (Inherited enumerators as not allowed).
190+
* Makes sure the resulting enumerator exactly matches an enumeration. (Inherited enumerators are not allowed).
191191

192192
* Allows enumerator values directly
193193
* `$user->setStatus(UserStatus::ACTIVE)` works
@@ -216,8 +216,7 @@ ordinal number by design.
216216
It implements `IteratorAggregate` and `Countable` to be directly iterable with `foreach` and countable with `count()`.
217217

218218
The `EnumSet` has a mutable and an immutable interface.
219-
Mutable methods starts with `set`, `attach` and `detach`.
220-
Immutable methods starts with `with` or `without`.
219+
Mutable methods starts with `set` or `remove` where immutable methods starts with `with`.
221220

222221
```php
223222
use MabeEnum\EnumSet;
@@ -227,36 +226,36 @@ $enumSet = new EnumSet('UserStatus', [UserStatus::ACTIVE()]);
227226

228227
// modify an EnumSet (mutable interface)
229228

230-
// attach enumerators (by value or by instance)
231-
$enumSet->attachEnumerators([UserStatus::INACTIVE, UserStatus::DELETED()]);
229+
// add enumerators (by value or by instance)
230+
$enumSet->addIterable([UserStatus::INACTIVE, UserStatus::DELETED()]);
232231
// or
233-
$enumSet->attachEnumerator(UserStatus::INACTIVE);
234-
$enumSet->attachEnumerator(UserStatus::DELETED());
232+
$enumSet->add(UserStatus::INACTIVE);
233+
$enumSet->add(UserStatus::DELETED());
235234

236-
// detach enumerators (by value or by instance)
237-
$enumSet->detachEnumerators([UserStatus::INACTIVE, UserStatus::DELETED()]);
235+
// remove enumerators (by value or by instance)
236+
$enumSet->removeIterable([UserStatus::INACTIVE, UserStatus::DELETED()]);
238237
// or
239-
$enumSet->detachEnumerator(UserStatus::INACTIVE);
240-
$enumSet->detachEnumerator(UserStatus::DELETED());
238+
$enumSet->remove(UserStatus::INACTIVE);
239+
$enumSet->remove(UserStatus::DELETED());
241240

242241

243242
// The immutable interface will create a new EnumSet for each modification
244243

245244
// add enumerators (by value or by instance)
246-
$enumSet = $enumSet->withEnumerators([UserStatus::INACTIVE, UserStatus::DELETED()]);
245+
$enumSet = $enumSet->withIterable([UserStatus::INACTIVE, UserStatus::DELETED()]);
247246
// or
248-
$enumSet = $enumSet->withEnumerator(UserStatus::INACTIVE);
249-
$enumSet = $enumSet->withEnumerator(UserStatus::DELETED());
247+
$enumSet = $enumSet->with(UserStatus::INACTIVE);
248+
$enumSet = $enumSet->with(UserStatus::DELETED());
250249

251-
// detach enumerators (by value or by instance)
252-
$enumSet->withoutEnumerators([UserStatus::INACTIVE, UserStatus::DELETED()]);
250+
// remove enumerators (by value or by instance)
251+
$enumSet->withoutIterable([UserStatus::INACTIVE, UserStatus::DELETED()]);
253252
// or
254-
$enumSet = $enumSet->withEnumerator(UserStatus::INACTIVE);
255-
$enumSet = $enumSet->withEnumerator(UserStatus::DELETED());
253+
$enumSet = $enumSet->without(UserStatus::INACTIVE);
254+
$enumSet = $enumSet->without(UserStatus::DELETED());
256255

257256

258-
// contains enumerators (by value or by instance)
259-
$enumSet->contains(UserStatus::INACTIVE); // bool
257+
// Tests if an enumerator exists (by value or by instance)
258+
$enumSet->has(UserStatus::INACTIVE); // bool
260259

261260

262261
// count the number of enumerators
@@ -347,14 +346,14 @@ count($enumMap);
347346

348347
// support for null aware exists check
349348
$enumMap[UserStatus::NULL] = null;
350-
isset($enumMap[UserStatus::NULL]); // false
351-
$enumMap->contains(UserStatus::NULL); // true
349+
isset($enumMap[UserStatus::NULL]); // false
350+
$enumMap->has(UserStatus::NULL); // true
352351

353352

354353
// iterating over the map
355354
foreach ($enumMap as $enum => $value) {
356355
get_class($enum); // UserStatus (enumerator object)
357-
gettype($value); // string (the value the enumerators maps to)
356+
gettype($value); // mixed (the value the enumerators maps to)
358357
}
359358

360359
// get a list of keys (= a list of enumerator objects)
@@ -415,6 +414,11 @@ var_dump($north2->is($north1)); // returns TRUE - equality works in both directi
415414
* No support for `EnumMap` or `EnumSet`.
416415

417416

417+
# Changelog
418+
419+
Changes are documented in the (release page)[https://github.com/marc-mabe/php-enum/releases].
420+
421+
418422
# Install
419423

420424
## Composer

src/EnumSet.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public function remove($enumerator): void
159159
* @return void
160160
* @throws InvalidArgumentException On an invalid given enumerator
161161
* @see add()
162+
* @see with()
162163
* @deprecated Will trigger deprecation warning in last 4.x and removed in 5.x
163164
*/
164165
public function attach($enumerator): void
@@ -172,6 +173,7 @@ public function attach($enumerator): void
172173
* @return void
173174
* @throws InvalidArgumentException On an invalid given enumerator
174175
* @see remove()
176+
* @see without()
175177
* @deprecated Will trigger deprecation warning in last 4.x and removed in 5.x
176178
*/
177179
public function detach($enumerator): void
@@ -536,6 +538,8 @@ public function withUnion(EnumSet $other): self
536538
* @param EnumSet $other EnumSet of the same enumeration to produce the union
537539
* @return static
538540
* @throws InvalidArgumentException If $other doesn't match the enumeration
541+
* @see withUnion()
542+
* @see setUnion()
539543
* @deprecated Will trigger deprecation warning in last 4.x and removed in 5.x
540544
*/
541545
public function union(EnumSet $other): self
@@ -563,6 +567,8 @@ public function withIntersect(EnumSet $other): self
563567
* @param EnumSet $other EnumSet of the same enumeration to produce the intersect
564568
* @return static
565569
* @throws InvalidArgumentException If $other doesn't match the enumeration
570+
* @see withIntersect()
571+
* @see setIntersect()
566572
* @deprecated Will trigger deprecation warning in last 4.x and removed in 5.x
567573
*/
568574
public function intersect(EnumSet $other): self
@@ -590,6 +596,8 @@ public function withDiff(EnumSet $other): self
590596
* @param EnumSet $other EnumSet of the same enumeration to produce the diff
591597
* @return static
592598
* @throws InvalidArgumentException If $other doesn't match the enumeration
599+
* @see withDiff()
600+
* @see setDiff()
593601
* @deprecated Will trigger deprecation warning in last 4.x and removed in 5.x
594602
*/
595603
public function diff(EnumSet $other): self
@@ -617,6 +625,8 @@ public function withSymDiff(EnumSet $other): self
617625
* @param EnumSet $other EnumSet of the same enumeration to produce the symmetric difference
618626
* @return static
619627
* @throws InvalidArgumentException If $other doesn't match the enumeration
628+
* @see withSymDiff()
629+
* @see setSymDiff()
620630
* @deprecated Will trigger deprecation warning in last 4.x and removed in 5.x
621631
*/
622632
public function symDiff(EnumSet $other): self

0 commit comments

Comments
 (0)