Skip to content

Commit

Permalink
Merge pull request #367 from HubSpot/feature/updateHintsAndLittleFixes
Browse files Browse the repository at this point in the history
Type hinting + cs fix
  • Loading branch information
ksvirkou-hubspot authored Dec 17, 2021
2 parents 1226978 + cd14454 commit a86b56c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Factory
* @param array $clientOptions options to be send with each request
* @param bool $wrapResponse wrap request response in own Response object
*/
public function __construct(array $config = [], Client $client = null, array $clientOptions = [], $wrapResponse = true)
public function __construct(array $config = [], Client $client = null, array $clientOptions = [], bool $wrapResponse = true)
{
if (is_null($client)) {
$client = new Client($config, null, $clientOptions, $wrapResponse);
Expand Down
10 changes: 4 additions & 6 deletions src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Client
* @param array $clientOptions options to be passed to Guzzle upon each request
* @param bool $wrapResponse wrap request response in own Response object
*/
public function __construct($config = [], $client = null, $clientOptions = [], $wrapResponse = true)
public function __construct(array $config = [], $client = null, array $clientOptions = [], bool $wrapResponse = true)
{
$this->clientOptions = $clientOptions;
$this->wrapResponse = $wrapResponse;
Expand Down Expand Up @@ -90,7 +90,7 @@ public function __construct($config = [], $client = null, $clientOptions = [], $
*
* @return ResponseInterface|\SevenShores\Hubspot\Http\Response
*/
public function request($method, $endpoint, array $options = [], $query_string = null, $requires_auth = true)
public function request(string $method, string $endpoint, array $options = [], $query_string = null, bool $requires_auth = true)
{
if ($requires_auth && empty($this->key)) {
throw new InvalidArgument('You must provide a Hubspot api key or token.');
Expand Down Expand Up @@ -127,7 +127,7 @@ public function request($method, $endpoint, array $options = [], $query_string =
*
* @return string
*/
protected function generateUrl($endpoint, $query_string = null, $requires_auth = true)
protected function generateUrl(string $endpoint, $query_string = null, $requires_auth = true)
{
$url = $endpoint.'?';

Expand All @@ -152,10 +152,8 @@ protected function generateUrl($endpoint, $query_string = null, $requires_auth =
/**
* @param string $query_string the query string to send to the endpoint
* @param string $addition addition query string to send to the endpoint
*
* @return string
*/
protected function addQuery($query_string, $addition)
protected function addQuery($query_string, $addition): string
{
$result = '';

Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Companies.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public function searchByDomain(
/**
* Returns a company with id $id.
*
* @param int $id
* @param array $params Array of optional parameters ['includeMergeAudits', 'includePropertyVersions']
* @param int $id
* @param array $params Array of optional parameters ['includeMergeAudits', 'includePropertyVersions']
*
* @see https://developers.hubspot.com/docs/methods/companies/get_company
*
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ protected function getAdditionalParams(array $params): array
protected function getDefaultOptions(): array
{
return [
'access' => 'PUBLIC_INDEXABLE'
'access' => 'PUBLIC_INDEXABLE',
];
}
}
4 changes: 1 addition & 3 deletions src/Utils/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ class OAuth2
* @param string $redirectURI The URL that you want the visitor redirected to after granting access to your app. For security reasons, this URL must use https.
* @param array $scopesArray a set of scopes that your app will need access to
* @param array $optionalScopesArray a set of optional scopes that your app will need access to
*
* @return string
*/
public static function getAuthUrl($clientId, $redirectURI, array $scopesArray = [], array $optionalScopesArray = [])
public static function getAuthUrl($clientId, $redirectURI, array $scopesArray = [], array $optionalScopesArray = []): string
{
return self::AUTHORIZE_URL.'?'.http_build_query([
'client_id' => $clientId,
Expand Down
4 changes: 1 addition & 3 deletions src/Utils/Webhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ class Webhooks
* @param string $signature hubspot signarute
* @param string $secret the Secret of your app
* @param string $requestBody a set of scopes that your app will need access to
*
* @return bool
*/
public static function isHubspotSignatureValid($signature, $secret, $requestBody)
public static function isHubspotSignatureValid($signature, $secret, $requestBody): bool
{
return $signature == hash('sha256', $secret.$requestBody);
}
Expand Down
11 changes: 3 additions & 8 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
/**
* Generate a query string.
*
* @param array $params
* @param int $encoding
*
* @return string
* @param int $encoding
*/
function build_query_string($params = [], $encoding = PHP_QUERY_RFC3986)
function build_query_string(array $params = [], $encoding = PHP_QUERY_RFC3986): string
{
if (empty($params)) {
return '';
Expand Down Expand Up @@ -43,10 +40,8 @@ function build_query_string($params = [], $encoding = PHP_QUERY_RFC3986)
* @param string $key the name of the query variable
* @param array $items an array of item values for the variable
* @param int $encoding
*
* @return string
*/
function build_batch_query_string($key, $items, $encoding = PHP_QUERY_RFC3986)
function build_batch_query_string($key, array $items, $encoding = PHP_QUERY_RFC3986): string
{
return array_reduce($items, function ($query, $item) use ($key, $encoding) {
return $query.'&'.url_encode($key, $encoding).'='.url_encode($item, $encoding);
Expand Down

0 comments on commit a86b56c

Please sign in to comment.