1 | <?php |
||
16 | class MiniProgramProvider extends AbstractProvider |
||
17 | { |
||
18 | use ArrayAccessorTrait; |
||
19 | use RequiredParameterTrait; |
||
20 | |||
21 | protected $appid; |
||
22 | protected $secret; |
||
23 | protected $jscode; |
||
24 | protected $responseUserInfo; |
||
25 | |||
26 | /** |
||
27 | * Constructs an OAuth 2.0 service provider. |
||
28 | * |
||
29 | * @param array $options An array of options to set on this provider. |
||
30 | * Options include `clientId`, `clientSecret`, `redirectUri`, and `state`. |
||
31 | * Individual providers may introduce more options, as needed. |
||
32 | * @param array $collaborators An array of collaborators that may be used to |
||
33 | * override this provider's default behavior. Collaborators include |
||
34 | * `grantFactory`, `requestFactory`, and `httpClient`. |
||
35 | * Individual providers may introduce more collaborators, as needed. |
||
36 | */ |
||
37 | 18 | public function __construct(array $options = [], array $collaborators = []) |
|
51 | |||
52 | /** |
||
53 | * Returns the base URL for authorizing a client. |
||
54 | * |
||
55 | * Eg. https://oauth.service.com/authorize |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | 3 | public function getBaseAuthorizationUrl() |
|
63 | |||
64 | /** |
||
65 | * Returns the base URL for requesting an access token. |
||
66 | * |
||
67 | * Eg. https://oauth.service.com/token |
||
68 | * |
||
69 | * @param array $params |
||
70 | * @return string |
||
71 | */ |
||
72 | 12 | public function getBaseAccessTokenUrl(array $params) |
|
76 | |||
77 | /** |
||
78 | * Requests an access token using a specified grant and option set. |
||
79 | * |
||
80 | * @param string $jsCode |
||
81 | * @param array $options |
||
82 | * @return AccessToken |
||
83 | */ |
||
84 | 9 | public function getAccessToken($jsCode, array $options = []) |
|
103 | |||
104 | /** |
||
105 | * Creates an access token from a response. |
||
106 | * |
||
107 | * The grant that was used to fetch the response can be used to provide |
||
108 | * additional context. |
||
109 | * |
||
110 | * @param array $response |
||
111 | * @param AbstractGrant $grant |
||
112 | * @return AccessToken |
||
113 | */ |
||
114 | 11 | protected function createAccessToken(array $response, AbstractGrant $grant) |
|
120 | |||
121 | /** |
||
122 | * Returns the URL for requesting the resource owner's details. |
||
123 | * |
||
124 | * @param AccessToken $token |
||
125 | * @return string |
||
126 | */ |
||
127 | 3 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
|
133 | |||
134 | /** |
||
135 | * Returns the default scopes used by this provider. |
||
136 | * |
||
137 | * This should only be the scopes that are required to request the details |
||
138 | * of the resource owner, rather than all the available scopes. |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | protected function getDefaultScopes() |
||
146 | |||
147 | /** |
||
148 | * Checks a provider response for errors. |
||
149 | * |
||
150 | * @throws IdentityProviderException |
||
151 | * @param ResponseInterface $response |
||
152 | * @param array|string $data Parsed response data |
||
153 | * @return void |
||
154 | */ |
||
155 | 9 | protected function checkResponse(ResponseInterface $response, $data) |
|
164 | |||
165 | /** |
||
166 | * Generates a resource owner object from a successful resource owner |
||
167 | * details request. |
||
168 | * |
||
169 | * @param array $response |
||
170 | * @param AccessToken $token |
||
171 | * @return ResourceOwnerInterface |
||
172 | */ |
||
173 | 3 | public function createResourceOwner(array $response, AccessToken $token) |
|
177 | |||
178 | /** |
||
179 | * Requests and returns the resource owner of given access token. |
||
180 | * |
||
181 | * @param AccessToken $token |
||
182 | * @return ResourceOwnerInterface |
||
183 | */ |
||
184 | 3 | public function getResourceOwner(AccessToken $token) |
|
194 | |||
195 | /** |
||
196 | * set by wx.getUserInfo(OBJECT)'s response data |
||
197 | * |
||
198 | * @param array $response |
||
199 | */ |
||
200 | 3 | public function setResponseUserInfo($response) |
|
204 | } |
||
205 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.