To parse `@stable` you can use: `preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)`

And yes, I meant that --stability should win over package explicit stability, because it's unlikely that both are given together but if a stability is explicitly given I guess the intent is to set it to that, so keeping it that way means no BC break.

So I would say it should use the first match in this order:

- --stability if set
- `@..` if found
- parseStability