style: auto-fix PHPCS violations via phpcbf
This commit is contained in:
@@ -109,11 +109,11 @@ class PR_Core_Pubchem_Client {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
return array(
|
||||
'formula' => $formula,
|
||||
'weight' => $weight,
|
||||
'cid' => $cid,
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,14 +130,14 @@ class PR_Core_Pubchem_Client {
|
||||
$body = $this->get_with_retry( $url );
|
||||
|
||||
if ( null === $body ) {
|
||||
return [];
|
||||
return array();
|
||||
}
|
||||
|
||||
$data = json_decode( $body, true );
|
||||
$synonyms = $data['InformationList']['Information'][0]['Synonym'] ?? [];
|
||||
$synonyms = $data['InformationList']['Information'][0]['Synonym'] ?? array();
|
||||
|
||||
if ( ! is_array( $synonyms ) ) {
|
||||
return [];
|
||||
return array();
|
||||
}
|
||||
|
||||
return array_slice( $synonyms, 0, self::MAX_SYNONYMS );
|
||||
@@ -176,10 +176,13 @@ class PR_Core_Pubchem_Client {
|
||||
*/
|
||||
private function get_once( string $url ): ?string {
|
||||
if ( function_exists( 'wp_remote_get' ) ) {
|
||||
$response = wp_remote_get( $url, [
|
||||
'timeout' => self::TIMEOUT,
|
||||
'headers' => [ 'Accept' => 'application/json' ],
|
||||
] );
|
||||
$response = wp_remote_get(
|
||||
$url,
|
||||
array(
|
||||
'timeout' => self::TIMEOUT,
|
||||
'headers' => array( 'Accept' => 'application/json' ),
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return null;
|
||||
@@ -194,13 +197,15 @@ class PR_Core_Pubchem_Client {
|
||||
}
|
||||
|
||||
// WP-CLI / plain PHP fallback.
|
||||
$context = stream_context_create( [
|
||||
'http' => [
|
||||
'timeout' => self::TIMEOUT,
|
||||
'header' => "Accept: application/json\r\n",
|
||||
'method' => 'GET',
|
||||
],
|
||||
] );
|
||||
$context = stream_context_create(
|
||||
array(
|
||||
'http' => array(
|
||||
'timeout' => self::TIMEOUT,
|
||||
'header' => "Accept: application/json\r\n",
|
||||
'method' => 'GET',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$body = @file_get_contents( $url, false, $context );
|
||||
return ( false === $body ) ? null : $body;
|
||||
|
||||
Reference in New Issue
Block a user