[PHP] Best practices: `array_find_key` on `Enum::cases`?

[email protected] (0xEAB) Wed, 29 Apr 2026 23:54:38 +0200
Newsgroups php.general
Message-ID <[email protected]>
I’ve written an enum method as follows.

```
public function getPrefixBitCount(): int
{
	return array_find_key(self::cases(), function(CidrMaskIPv4 $value): bool {
		return $value === $this;
	});
}
```

Is this usage of `Enum::cases()` fine?
Can the order of cases in the returned array be relied on?
Can the numeric keys of the returned array be relied on?