Skip to content

Commit 806f25b

Browse files
authored
Merge pull request #2 from kudmni/patch-1
Fix PHP 8.3 deprecations
2 parents da4b9dd + 2559b2e commit 806f25b

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

src/UserAgentParser.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function blacklistCheck($input)
110110
'(',
111111
')',
112112
] as $string) {
113-
if (stripos($input, $string) !== false) {
113+
if (isset($input) && stripos($input, $string) !== false) {
114114
throw new Exceptions\FormatException('Invalid User-agent format (`' . trim($this->product . '/' . $this->version, '/') . '`). Examples of valid User-agents: `MyCustomBot`, `MyFetcher-news`, `MyCrawler/2.1` and `MyBot-images/1.2`. See also ' . self::RFC_README);
115115
}
116116
}
@@ -137,16 +137,15 @@ private function strip($string)
137137
*/
138138
private function validateVersion()
139139
{
140-
$this->blacklistCheck($this->version);
141-
if (!empty($this->version) &&
142-
(
143-
str_replace('+', '', filter_var($this->version, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)) !== $this->version ||
144-
version_compare($this->version, '0.0.1', '>=') === false
145-
)
146-
) {
147-
throw new Exceptions\VersionException("Invalid version format (`$this->version`). See http://semver.org/ for guidelines. In addition, dev/alpha/beta/rc tags is disallowed. See also " . self::RFC_README);
140+
if (!empty($this->version)) {
141+
$this->blacklistCheck($this->version);
142+
if (str_replace('+', '', filter_var($this->version, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)) !== $this->version
143+
|| version_compare($this->version, '0.0.1', '>=') === false
144+
) {
145+
throw new Exceptions\VersionException("Invalid version format (`$this->version`). See http://semver.org/ for guidelines. In addition, dev/alpha/beta/rc tags is disallowed. See also " . self::RFC_README);
146+
}
147+
$this->version = trim($this->version, '.0');
148148
}
149-
$this->version = trim($this->version, '.0');
150149
return true;
151150
}
152151

0 commit comments

Comments
 (0)