smr.inc.php: improve return type of getWeightedRandom
smr.inc.php: improve return type of getWeightedRandom

Mathematically, this function must return one of the array keys
(which should be either an int or string), but algorithmically it
could return `null`. This caused Scrutinizer to worry.

To help Scrutinizer understand that we can't return null, and to
ensure that a mathematical error does not escape this function, we
can do the following:

* Add the `string|int` return type hint. These are the only types
  that we expect to use as array keys.

* Throw an exception if we fail to return one of the array keys.

(Also removed modifying `$choices` by reference while we're here.)

hemberger/smr,smrealms/smr,smrealms/smr,hemberger/smr,hemberger/smr,hemberger/smr,smrealms/smr