Skip to content

Commit df04ba8

Browse files
committed
Improve PHPdoc
1 parent 17bb840 commit df04ba8

28 files changed

+168
-161
lines changed

lib/AuditLogs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AuditLogs
3737
*
3838
* @throws Exception\WorkOSException
3939
*
40-
* @return \WorkOS\Resource\AuditLogCreateEventStatus
40+
* @return Resource\AuditLogCreateEventStatus
4141
*/
4242

4343
public function createEvent($organizationId, $event, $idempotencyKey = null)

lib/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function setRequestClient($requestClient)
4444
* @throws \WorkOS\Exception\NotFoundException if a 404 status code is returned
4545
* @throws \WorkOS\Exception\BadRequestException if a 400 status code is returned
4646
*
47-
* @return \WorkOS\Resource\Response
47+
* @return Resource\Response
4848
*/
4949
public static function request($method, $path, $headers = null, $params = null, $withAuth = false)
5050
{

lib/DirectorySync.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ class DirectorySync
2020
* @param null|string $before Directory ID to look before
2121
* @param null|string $after Directory ID to look after
2222
* @param null|string $organizationId Unique ID for an organization
23-
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
23+
* @param Resource\Order $order The Order in which to paginate records
2424
*
2525
* @throws Exception\WorkOSException
2626
*
27-
* @return array An array containing the following:
28-
* null|string Directory ID to use as before cursor
29-
* null|string Directory ID to use as after cursor
30-
* array \WorkOS\Resource\Directory instances
27+
* @return array{?string, ?string, Resource\Directory[]} An array containing the Directory ID to use as before and after cursor, and an array of Directory instances
3128
*/
3229
public function listDirectories(
3330
$domain = null,
@@ -74,14 +71,11 @@ public function listDirectories(
7471
* @param int $limit Maximum number of records to return
7572
* @param null|string $before Directory Group ID to look before
7673
* @param null|string $after Directory Group ID to look after
77-
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
74+
* @param Resource\Order $order The Order in which to paginate records
7875
*
7976
* @throws Exception\WorkOSException
8077
*
81-
* @return array An array containing the following:
82-
* null|string Directory Group ID to use as before cursor
83-
* null|string Directory Group ID to use as after cursor
84-
* array \WorkOS\Resource\DirectoryGroup instances
78+
* @return array{?string, ?string, Resource\DirectoryGroup[]} An array containing the Directory Group ID to use as before and after cursor, and an array of Directory Group instances
8579
*/
8680
public function listGroups(
8781
$directory = null,
@@ -130,7 +124,7 @@ public function listGroups(
130124
*
131125
* @throws Exception\WorkOSException
132126
*
133-
* @return \WorkOS\Resource\DirectoryGroup
127+
* @return Resource\DirectoryGroup
134128
*/
135129
public function getGroup($directoryGroup)
136130
{
@@ -155,14 +149,11 @@ public function getGroup($directoryGroup)
155149
* @param int $limit Maximum number of records to return
156150
* @param null|string $before Directory User ID to look before
157151
* @param null|string $after Directory User ID to look after
158-
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
152+
* @param Resource\Order $order The Order in which to paginate records
159153
*
160-
* @throws Exception\WorkOSException
154+
* @return array{?string, ?string, Resource\DirectoryUser[]} An array containing the Directory User ID to use as before and after cursor, and an array of Directory User instances
161155
*
162-
* @return array An array containing the following:
163-
* null|string Directory User ID to use as before cursor
164-
* null|string Directory User ID to use as after cursor
165-
* array \WorkOS\Resource\DirectoryUser instances
156+
* @throws Exception\WorkOSException
166157
*/
167158
public function listUsers(
168159
$directory = null,
@@ -211,7 +202,7 @@ public function listUsers(
211202
*
212203
* @throws Exception\WorkOSException
213204
*
214-
* @return \WorkOS\Resource\DirectoryUser
205+
* @return Resource\DirectoryUser
215206
*/
216207
public function getUser($directoryUser)
217208
{
@@ -235,7 +226,7 @@ public function getUser($directoryUser)
235226
*
236227
* @throws Exception\WorkOSException
237228
*
238-
* @return \WorkOS\Resource\Response
229+
* @return Resource\Response
239230
*/
240231
public function deleteDirectory($directory)
241232
{
@@ -259,7 +250,7 @@ public function deleteDirectory($directory)
259250
*
260251
* @throws Exception\WorkOSException
261252
*
262-
* @return \WorkOS\Resource\Directory
253+
* @return Resource\Directory
263254
*/
264255
public function getDirectory($directory)
265256
{

lib/Exception/BaseRequestException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace WorkOS\Exception;
44

5+
use WorkOS\Resource\Response;
6+
57
/**
68
* Class BaseRequestException.
79
*
@@ -20,7 +22,7 @@ class BaseRequestException extends \Exception implements WorkOSException
2022
/**
2123
* BaseRequestException constructor.
2224
*
23-
* @param \WorkOS\Resource\Response $response
25+
* @param Response $response
2426
* @param null|string $message Exception message
2527
*/
2628
public function __construct($response, $message = null)

lib/MFA.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public function enrollFactor(
4848
}
4949

5050
$params = [
51-
"type" => $type,
52-
"totp_issuer" => $totpIssuer,
53-
"totp_user" => $totpUser,
54-
"phone_number" => $phoneNumber
55-
];
51+
"type" => $type,
52+
"totp_issuer" => $totpIssuer,
53+
"totp_user" => $totpUser,
54+
"phone_number" => $phoneNumber
55+
];
5656
$response = Client::request(
5757
Client::METHOD_POST,
5858
$enrollPath,
@@ -74,6 +74,8 @@ public function enrollFactor(
7474
*
7575
* @param string $authenticationFactorId - ID of the authentication factor
7676
* @param string|null $smsTemplate - Optional parameter to customize the message for sms type factors. Must include "{{code}}" if used.
77+
*
78+
* @return Resource\AuthenticationChallengeTotp|Resource\AuthenticationChallengeSms
7779
*/
7880
public function challengeFactor(
7981
$authenticationFactorId,
@@ -198,6 +200,8 @@ public function getFactor($authenticationFactorId)
198200
*
199201
* @param string $authenticationFactorId - WorkOS Factor ID
200202
*
203+
* @return Resource\Response
204+
*
201205
* @throws Exception\WorkOSException
202206
*/
203207
public function deleteFactor($authenticationFactorId)

lib/Organizations.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ class Organizations
1919
* @param int $limit Maximum number of records to return
2020
* @param null|string $before Organization ID to look before
2121
* @param null|string $after Organization ID to look after
22-
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
22+
* @param Resource\Order $order The Order in which to paginate records
2323
*
24-
* @throws Exception\WorkOSException
24+
* @return array{?string, ?string, Resource\Organization[]} An array containing the Organization ID to use as before and after cursor, and an array of Organization instances
2525
*
26-
* @return array An array containing the following:
27-
* null|string Organization ID to use as before cursor
28-
* null|string Organization ID to use as after cursor
29-
* array \WorkOS\Resource\Organization instances
26+
* @throws Exception\WorkOSException
3027
*/
3128
public function listOrganizations(
3229
$domains = null,
@@ -73,7 +70,7 @@ public function listOrganizations(
7370
*
7471
* @throws Exception\WorkOSException
7572
*
76-
* @return \WorkOS\Resource\Organization
73+
* @return Resource\Organization
7774
*/
7875
public function createOrganization($name, $domains = null, $allowProfilesOutsideOrganization = null, $idempotencyKey = null, $domain_data = null)
7976
{
@@ -141,7 +138,7 @@ public function updateOrganization($organization, $domains = null, $name = null,
141138
*
142139
* @throws Exception\WorkOSException
143140
*
144-
* @return \WorkOS\Resource\Organization
141+
* @return Resource\Organization
145142
*/
146143
public function getOrganization($organization)
147144
{
@@ -159,7 +156,7 @@ public function getOrganization($organization)
159156
*
160157
* @throws Exception\WorkOSException
161158
*
162-
* @return \WorkOS\Resource\Response
159+
* @return Resource\Response
163160
*/
164161
public function deleteOrganization($organization)
165162
{
@@ -183,8 +180,7 @@ public function deleteOrganization($organization)
183180
*
184181
* @throws Exception\WorkOSException
185182
*
186-
* @return array An array containing the following:
187-
* array \WorkOS\Resource\Role instances
183+
* @return array{0: Resource\Role[]} An array containing the list of Role instances
188184
*/
189185
public function listOrganizationRoles($organizationId)
190186
{

lib/Passwordless.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ class Passwordless
1313
* Generates a passwordless session.
1414
*
1515
* @param string $email Email address of the user that the session is to be created for
16-
* @param null|string $redirectURI URI to direct the user to user to upon authenticating through the passwordless link
16+
* @param null|string $redirectUri URI to direct the user to user to upon authenticating through the passwordless link
1717
* @param null|string $state Encoded string used to manage application state
1818
* @param string $type The only supported ConnectionType at the time of this writing is MagicLink
19-
* @param $connection the unique WorkOS connection_ID
20-
* @param $expiresIn The number of seconds the Passwordless Session should live before expiring.
19+
* @param string $connection Unique WorkOS connection_ID
20+
* @param int $expiresIn Number of seconds the Passwordless Session should live before expiring.
2121
*
2222
* @throws Exception\WorkOSException
2323
*
24-
* @return \WorkOS\Resource\PasswordlessSession
24+
* @return Resource\PasswordlessSession
2525
*/
2626
public function createSession($email, $redirectUri, $state, $type, $connection, $expiresIn)
2727
{
@@ -56,11 +56,11 @@ public function createSession($email, $redirectUri, $state, $type, $connection,
5656
/**
5757
* Send a passwordless link via email from WorkOS.
5858
*
59-
* @param \WorkOS\Resource\PasswordlessSession $session Passwordless session generated through Passwordless->createSession
59+
* @param Resource\PasswordlessSession $session Passwordless session generated through Passwordless->createSession
6060
*
6161
* @throws Exception\WorkOSException
6262
*
63-
* @return boolean true
63+
* @return true
6464
*/
6565
public function sendSession($session)
6666
{

lib/Portal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Portal
2121
*
2222
* @throws Exception\WorkOSException
2323
*
24-
* @return \WorkOS\Resource\PortalLink
24+
* @return Resource\PortalLink
2525
*/
2626
public function generateLink($organization, $intent, $returnUrl = null, $successUrl = null)
2727
{

lib/RequestClient/CurlRequestClient.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace WorkOS\RequestClient;
44

5+
use WorkOS\Client;
6+
use WorkOS\Exception\GenericException;
7+
58
/**
69
* Class CurlRequestClient.
710
*/
@@ -13,7 +16,7 @@ class CurlRequestClient implements RequestClientInterface
1316
* @param null|array $headers Headers for request
1417
* @param null|array $params Associative array that'll be passed as query parameters or form data
1518
*
16-
* @throws \WorkOS\Exception\GenericException if a client level exception is encountered
19+
* @throws GenericException if a client level exception is encountered
1720
*
1821
* @return array An array composed of the result string, response headers and status code
1922
*/
@@ -26,14 +29,14 @@ public function request($method, $url, $headers = null, $params = null)
2629
$opts = [\CURLOPT_RETURNTRANSFER => 1];
2730

2831
switch ($method) {
29-
case \WorkOS\Client::METHOD_GET:
32+
case Client::METHOD_GET:
3033
if (!empty($params)) {
3134
$url .= "?" . http_build_query($params);
3235
}
3336

3437
break;
3538

36-
case \WorkOS\CLIENT::METHOD_POST:
39+
case Client::METHOD_POST:
3740
\array_push($headers, "Content-Type: application/json");
3841

3942
$opts[\CURLOPT_POST] = 1;
@@ -44,7 +47,7 @@ public function request($method, $url, $headers = null, $params = null)
4447

4548
break;
4649

47-
case \WorkOS\CLIENT::METHOD_DELETE:
50+
case Client::METHOD_DELETE:
4851

4952
$opts[\CURLOPT_CUSTOMREQUEST] = 'DELETE';
5053

@@ -55,7 +58,7 @@ public function request($method, $url, $headers = null, $params = null)
5558

5659
break;
5760

58-
case \WorkOS\CLIENT::METHOD_PUT:
61+
case Client::METHOD_PUT:
5962

6063
\array_push($headers, "Content-Type: application/json");
6164

@@ -103,7 +106,7 @@ private function execute($opts)
103106
$msg = \curl_error($curl);
104107
\curl_close($curl);
105108

106-
throw new \WorkOS\Exception\GenericException($msg, ["curlErrno" => $errno]);
109+
throw new GenericException($msg, ["curlErrno" => $errno]);
107110
} else {
108111
// Unsure how versions of cURL and PHP correlate so using the legacy
109112
// reference for getting the last response code

lib/RequestClient/RequestClientInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace WorkOS\RequestClient;
44

5+
use WorkOS\Exception\GenericException;
6+
57
/**
68
* Interface RequestClientInterface.
79
*/
@@ -13,7 +15,7 @@ interface RequestClientInterface
1315
* @param null|array $headers Headers for request
1416
* @param null|array $params Associative array that'll be passed as query parameters or form data
1517
*
16-
* @throws \WorkOS\Exception\GenericException if a client level exception is encountered
18+
* @throws GenericException if a client level exception is encountered
1719
*
1820
* @return array An array composed of the result string, response headers and status code
1921
*/

0 commit comments

Comments
 (0)