PHPStan level 3 #1603

Merged
nupplaPhil merged 15 commits from Art4/friendica-addons:phpstan-level-3 into develop 2025-04-27 02:17:42 +02:00
Showing only changes of commit 38a8e9a169 - Show all commits

remove obvious type cast

Art4 2025-03-14 08:15:02 +00:00

View file

@ -368,12 +368,12 @@ class Services_Libravatar
// important bit out.
if (filter_var($identifier, FILTER_VALIDATE_EMAIL)) {
$email = explode('@', $identifier);
return (string) $email[1];
return $email[1];
Art4 marked this conversation as resolved Outdated

I'm surprised by this, explode() reportedly only returns strings in the output array. What case is this meant to address?

I'm surprised by this, `explode()` reportedly only returns strings in the output array. What case is this meant to address?

I was surprised too, but thought PHPStan complains because explode() could also return false. But now I removed the type cast and PHPStan don't show an error anymore. 🤷

I was surprised too, but thought PHPStan complains because `explode()` could also return `false`. But now I removed the type cast and PHPStan don't show an error anymore. 🤷
}
//OpenID
$url = parse_url($identifier);
$domain = (string) $url['host'];
$domain = $url['host'];
Art4 marked this conversation as resolved Outdated

parse_url() only returns an integer for the port key, this is superfluous.

`parse_url()` only returns an integer for the `port` key, this is superfluous.

Same as above: #1603 (comment)

Same as above: https://git.friendi.ca/friendica/friendica-addons/pulls/1603#issuecomment-196305
if (isset($url['port']) && $url['scheme'] === 'http'
&& $url['port'] != 80
|| isset($url['port']) && $url['scheme'] === 'https'