1 | <?php |
||
18 | class Apple extends AbstractProvider |
||
19 | { |
||
20 | use BearerAuthorizationTrait; |
||
21 | |||
22 | /** |
||
23 | * Default scopes |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | public $defaultScopes = ['name', 'email']; |
||
28 | |||
29 | /** |
||
30 | * @var string the team id |
||
31 | */ |
||
32 | protected $teamId; |
||
33 | |||
34 | /** |
||
35 | * @var string the key file id |
||
36 | */ |
||
37 | protected $keyFileId; |
||
38 | |||
39 | /** |
||
40 | * @var string the key file path |
||
41 | */ |
||
42 | protected $keyFilePath; |
||
43 | |||
44 | /** |
||
45 | * Constructs Apple's OAuth 2.0 service provider. |
||
46 | * |
||
47 | * @param array $options |
||
48 | * @param array $collaborators |
||
49 | */ |
||
50 | 14 | public function __construct(array $options = [], array $collaborators = []) |
|
66 | |||
67 | /** |
||
68 | * Creates an access token from a response. |
||
69 | * |
||
70 | * The grant that was used to fetch the response can be used to provide |
||
71 | * additional context. |
||
72 | * |
||
73 | * @param array $response |
||
74 | * @param AbstractGrant $grant |
||
75 | * @return AccessTokenInterface |
||
76 | */ |
||
77 | protected function createAccessToken(array $response, AbstractGrant $grant) |
||
78 | { |
||
79 | return new AppleAccessToken($this->getHttpClient(), $response); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Get the string used to separate scopes. |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | 3 | protected function getScopeSeparator() |
|
91 | |||
92 | /** |
||
93 | * Change response mode when scope requires it |
||
94 | * |
||
95 | * @param array $options |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | 3 | protected function getAuthorizationParameters(array $options) |
|
107 | |||
108 | /** |
||
109 | * @param AccessToken $token |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | 2 | protected function fetchResourceOwnerDetails(AccessToken $token) |
|
114 | { |
||
115 | 2 | return json_decode(array_key_exists('user', $_GET) ? $_GET['user'] |
|
116 | 2 | : (array_key_exists('user', $_POST) ? $_POST['user'] : '[]'), true) ?: []; |
|
117 | } |
||
118 | |||
119 | /** |
||
120 | * Get authorization url to begin OAuth flow |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | 3 | public function getBaseAuthorizationUrl() |
|
128 | |||
129 | /** |
||
130 | * Get access token url to retrieve token |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | 1 | public function getBaseAccessTokenUrl(array $params) |
|
138 | |||
139 | /** |
||
140 | * Get provider url to fetch user details |
||
141 | * |
||
142 | * @param AccessToken $token |
||
143 | * |
||
144 | * @return string |
||
145 | * @throws Exception |
||
146 | */ |
||
147 | 1 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
|
151 | |||
152 | /** |
||
153 | * Get the default scopes used by this provider. |
||
154 | * |
||
155 | * This should not be a complete list of all scopes, but the minimum |
||
156 | * required for the provider user interface! |
||
157 | * |
||
158 | * @return array |
||
159 | */ |
||
160 | 2 | protected function getDefaultScopes() |
|
164 | |||
165 | /** |
||
166 | * Check a provider response for errors. |
||
167 | * |
||
168 | * @param ResponseInterface $response |
||
169 | * @param array $data Parsed response data |
||
170 | * @return void |
||
171 | * @throws AppleAccessDeniedException |
||
172 | */ |
||
173 | 1 | protected function checkResponse(ResponseInterface $response, $data) |
|
174 | { |
||
175 | 1 | if ($response->getStatusCode() >= 400) { |
|
176 | 1 | throw new AppleAccessDeniedException( |
|
177 | 1 | array_key_exists('error', $data) ? $data['error'] : $response->getReasonPhrase(), |
|
178 | 1 | array_key_exists('code', $data) ? $data['code'] : $response->getStatusCode(), |
|
179 | 1 | $response |
|
|
|||
180 | ); |
||
181 | } |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * Generate a user object from a successful user details request. |
||
186 | * |
||
187 | * @param array $response |
||
188 | * @param AccessToken $token |
||
189 | * @return AppleResourceOwner |
||
190 | */ |
||
191 | 1 | protected function createResourceOwner(array $response, AccessToken $token) |
|
205 | |||
206 | /** |
||
207 | * {@inheritDoc} |
||
208 | */ |
||
209 | public function getAccessToken($grant, array $options = []) |
||
232 | |||
233 | /** |
||
234 | * @return Key |
||
235 | */ |
||
236 | 1 | public function getLocalKey() |
|
240 | } |
||
241 |
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: