Skip to content

Commit

Permalink
fix php deprecated warning when passing null as subject in preg_match…
Browse files Browse the repository at this point in the history
  • Loading branch information
julienbornstein authored Feb 3, 2022
1 parent 10d919b commit 2050027
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Mobile_Detect.php
Original file line number Diff line number Diff line change
Expand Up @@ -1450,13 +1450,17 @@ public function is($key, $userAgent = null, $httpHeaders = null)
* the User-Agent string.
*
* @param $regex
* @param string $userAgent
* @param string $userAgent
* @return bool
*
* @todo: search in the HTTP headers too.
*/
public function match($regex, $userAgent = null)
{
if (!\is_string($userAgent) && !\is_string($this->userAgent)) {
return false;
}

$match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
// If positive match is found, store the results for debug.
if ($match) {
Expand Down

0 comments on commit 2050027

Please sign in to comment.