This is a bad idea. You are relying on a having an error handler turning warnings into exceptions, which cannot be assumed by a generic library (thus, turning warnings into exception is often enabled in dev environments and disabled in prod for instance).

The proper way is to make the warning silent and to check the return value: it is ``false`` for invalid pattern and ``0`` for non-matching pattern (and ``1`` for a matching pattern) as I said previously. The other solution is to register a dedicated error handler before the call and restoring the error handler after that, to be sure an exception is thrown.
The fact that PHP handles the error handling both with a warning and the return value indeed makes it messy to handle errors in calling code, as the warning has to be dropped.