Skip to content

Commit

Permalink
Revert phpstan :closes: #7042
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Nov 1, 2024
1 parent c2e65f0 commit 37e9f6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion inc/Engine/Plugin/UpdaterApiCommonSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public static function get_subscribed_events() {
* @param string $url Requested URL.
* @return array An array of requested arguments
*/
public function maybe_set_rocket_user_agent( $request, string $url ) {
public function maybe_set_rocket_user_agent( $request, $url ) {
if ( ! is_string( $url ) ) { // @phpstan-ignore-line GH #7042 - $url variable may be change by other plugins to something else than string.
return $request;
}

if ( strpos( $url, self::API_HOST ) !== false ) {
$request['user-agent'] = sprintf( '%s;%s', $request['user-agent'], $this->get_rocket_user_agent() );
}
Expand Down
6 changes: 5 additions & 1 deletion inc/Engine/Plugin/UpdaterSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ public static function get_subscribed_events() {
* @param string $url The request URL.
* @return array Updated array of HTTP request arguments.
*/
public function exclude_rocket_from_wp_updates( $request, string $url ) {
public function exclude_rocket_from_wp_updates( $request, $url ) {
if ( ! is_string( $url ) ) { // @phpstan-ignore-line GH #7042 - $url variable may be change by other plugins to something else than string.
return $request;
}

if ( ! preg_match( '@^https?://api.wordpress.org/plugins/update-check(/|\?|$)@', $url ) || empty( $request['body']['plugins'] ) ) {
// Not a plugin update request. Stop immediately.
return $request;
Expand Down

0 comments on commit 37e9f6c

Please sign in to comment.