Skip to content

Commit f8a7457

Browse files
committed
🚿 reduce empty() usages
1 parent a417913 commit f8a7457

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/Core/AuthenticatedUser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function set_displayName(string|null $displayName):void{
130130

131131
$displayName = trim($displayName);
132132

133-
if(!empty($displayName)){
133+
if($displayName !== ''){
134134
$this->displayName = $displayName;
135135
}
136136

src/Core/OAuth1Provider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function getRequestTokenRequestParams():array{
104104
protected function parseTokenResponse(ResponseInterface $response, bool|null $checkCallbackConfirmed = null):AccessToken{
105105
$data = QueryUtil::parse(MessageUtil::decompress($response));
106106

107-
if(empty($data)){
107+
if($data === []){
108108
throw new ProviderException('unable to parse token response');
109109
}
110110

src/Core/OAuth2Provider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function getAuthorizationURLRequestParams(array $params, array $scopes
8585
'type' => 'web_server',
8686
]);
8787

88-
if(!empty($scopes)){
88+
if($scopes !== []){
8989
$params['scope'] = implode($this::SCOPES_DELIMITER, $scopes);
9090
}
9191

src/Providers/Deezer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function getAccessTokenRequestBodyParams(string $code):array{
8989
protected function getTokenResponseData(ResponseInterface $response):array{
9090
$data = trim(MessageUtil::getContents($response));
9191

92-
if(empty($data)){
92+
if($data === ''){
9393
throw new ProviderException('invalid response');
9494
}
9595

src/Providers/LastFM.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public function scrobble(array $tracks):array{
294294
$this->addScrobble($track);
295295
}
296296

297-
if(empty($this->scrobbles)){
297+
if($this->scrobbles === []){
298298
throw new InvalidArgumentException('no tracks to scrobble'); // @codeCoverageIgnore
299299
}
300300

@@ -368,7 +368,7 @@ protected function construct():void{
368368

369369
$this->{$var} = trim($this->{$var});
370370

371-
if(empty($this->{$var})){
371+
if($this->{$var} === ''){
372372
throw new InvalidArgumentException(sprintf('variable "%s" must not be empty', $var));
373373
}
374374
}

src/Storage/OAuthStorageAbstract.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function setLogger(LoggerInterface $logger):static{
7777
protected function getProviderName(string $provider):string{
7878
$name = trim($provider);
7979

80-
if(empty($name)){
80+
if($name === ''){
8181
throw new OAuthStorageException('provider name must not be empty');
8282
}
8383

0 commit comments

Comments
 (0)