Skip to content

Commit 1c4a8b3

Browse files
committed
Add Type::toBitwiseNotType() to AccessoryDecimalIntegerStringType
This class was added on the `unsealed` branch and didn't exist when the `Type::toBitwiseNotType()` interface method was introduced in the merged Group 3 refactor — sync up the missing override so the class is instantiable again. Body matches the other accessory string types: when not inverted the type is guaranteed non-empty, so `~$s` keeps the non-empty accessory. The decimal-integer property itself doesn't survive bitwise-not, so the accessory is dropped.
1 parent ff9424d commit 1c4a8b3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/Type/Accessory/AccessoryDecimalIntegerStringType.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ public function toAbsoluteNumber(): Type
220220
return $this->toNumber()->toAbsoluteNumber();
221221
}
222222

223+
public function toBitwiseNotType(): Type
224+
{
225+
// Decimal integer strings are non-empty when not inverted
226+
// (`"0"` / `"123"` are still at least one character). `~$s`
227+
// returns a string of the same length, so the non-empty flag
228+
// survives. The decimal-integer property doesn't survive the
229+
// bitwise-not, hence we drop the accessory.
230+
return $this->isNonEmptyString()->yes()
231+
? new IntersectionType([new StringType(), new AccessoryNonEmptyStringType()])
232+
: new StringType();
233+
}
234+
223235
public function toBoolean(): BooleanType
224236
{
225237
return $this->isNonFalsyString()->negate()->toBooleanType();

0 commit comments

Comments
 (0)