1 | <?php |
||
12 | class Zoho extends AbstractProvider |
||
13 | { |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $endpoint = "https://accounts.zoho.com"; |
||
18 | protected $accessType = "online"; |
||
19 | |||
20 | /** |
||
21 | * Zoho constructor. |
||
22 | * @param array $options |
||
23 | * @param array $collaborators |
||
24 | */ |
||
25 | 20 | public function __construct(array $options = [], array $collaborators = []) |
|
26 | { |
||
27 | 20 | parent::__construct($options, $collaborators); |
|
28 | |||
29 | 20 | foreach (['clientId', 'clientSecret', 'redirectUri'] as $key) { |
|
30 | 20 | if (!isset($options[$key])) { |
|
31 | 20 | throw new \InvalidArgumentException($key . " is missing"); |
|
32 | } |
||
33 | } |
||
34 | 20 | } |
|
35 | |||
36 | /** |
||
37 | * Returns the base URL for authorizing a client. |
||
38 | * |
||
39 | * Eg. https://oauth.service.com/authorize |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | 4 | public function getBaseAuthorizationUrl() |
|
47 | |||
48 | /** |
||
49 | * Returns the base URL for requesting an access token. |
||
50 | * |
||
51 | * Eg. https://oauth.service.com/token |
||
52 | * |
||
53 | * @param array $params |
||
54 | * @return string |
||
55 | */ |
||
56 | 8 | public function getBaseAccessTokenUrl(array $params) |
|
60 | |||
61 | /** |
||
62 | * Returns the URL for requesting the resource owner's details. |
||
63 | * |
||
64 | * @param AccessToken $token |
||
65 | * @return string |
||
66 | */ |
||
67 | 2 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
|
71 | |||
72 | /** |
||
73 | * @param mixed|null $token |
||
74 | * @return array|void |
||
75 | */ |
||
76 | protected function getAuthorizationHeaders($token = null) |
||
80 | |||
81 | /** |
||
82 | * @param array $options |
||
83 | * @return array |
||
84 | */ |
||
85 | 2 | protected function getAuthorizationParameters(array $options) |
|
86 | { |
||
87 | 2 | if (empty($options['state'])) { |
|
88 | 2 | $options['state'] = $this->getRandomState(); |
|
89 | } |
||
90 | |||
91 | 2 | if (empty($options['scope'])) { |
|
92 | 2 | $options['scope'] = $this->getDefaultScopes(); |
|
93 | } |
||
94 | |||
95 | $options += [ |
||
96 | 2 | 'response_type' => 'code', |
|
97 | 'approval_prompt' => 'auto' |
||
98 | ]; |
||
99 | |||
100 | 2 | if (is_array($options['scope'])) { |
|
101 | 2 | $separator = $this->getScopeSeparator(); |
|
102 | 2 | $options['scope'] = implode($separator, $options['scope']); |
|
103 | } |
||
104 | |||
105 | // Store the state as it may need to be accessed later on. |
||
106 | 2 | $this->state = $options['state']; |
|
107 | |||
108 | // Business code layer might set a different redirect_uri parameter |
||
109 | // depending on the context, leave it as-is |
||
110 | 2 | if (!isset($options['redirect_uri'])) { |
|
111 | 2 | $options['redirect_uri'] = $this->redirectUri; |
|
112 | } |
||
113 | |||
114 | 2 | $options['client_id'] = $this->clientId; |
|
115 | |||
116 | 2 | if (isset($options['access_type']) && in_array($options['access_type'], ['offline', 'online'])) { |
|
117 | $options['access_type'] = $this->accessType; |
||
118 | } |
||
119 | |||
120 | 2 | return $options; |
|
121 | } |
||
122 | |||
123 | /** |
||
124 | * Returns the default scopes used by this provider. |
||
125 | * |
||
126 | * This should only be the scopes that are required to request the details |
||
127 | * of the resource owner, rather than all the available scopes. |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | 4 | protected function getDefaultScopes() |
|
135 | |||
136 | /** |
||
137 | * Checking response to see if provider returned any error |
||
138 | * |
||
139 | * @param ResponseInterface $response |
||
140 | * @param array|string $data Parsed response data |
||
141 | * @return void |
||
142 | * @throws IdentityProviderException |
||
143 | */ |
||
144 | 4 | protected function checkResponse(ResponseInterface $response, $data) |
|
151 | |||
152 | /** |
||
153 | * Generates a resource owner object from a successful resource owner |
||
154 | * details request. |
||
155 | * |
||
156 | * @param array $response |
||
157 | * @param AccessToken $token |
||
158 | * @return ZohoUser |
||
159 | */ |
||
160 | protected function createResourceOwner(array $response, AccessToken $token) |
||
164 | } |
||
165 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: