Skip to content

Commit 779afad

Browse files
committed
Adds a PHP version check for filter options
1 parent db06d33 commit 779afad

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Log/Webhook.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,14 @@ public function setup(array $options)
122122
throw new Exception('no uri given');
123123
}
124124

125-
if (!filter_var($options['uri'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
125+
// PHP >7.2 deprecated the filter options and enabled them by default
126+
if (version_compare(PHP_VERSION, '7.2.0', '<')) {
127+
$filterOptions = FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED;
128+
} else {
129+
$filterOptions = null;
130+
}
131+
132+
if (!filter_var($options['uri'], FILTER_VALIDATE_URL, $filterOptions)) {
126133
throw new Exception('webhook URI is invalid');
127134
}
128135

0 commit comments

Comments
 (0)