Skip to content

Commit 4683644

Browse files
Make workos-php compatible with PHP 7.3 (#263)
* Make workos-php compatible with PHP 7.3 * run tests going back to php 7.3 --------- Co-authored-by: Nick Nisi <nick.nisi@workos.com>
1 parent 11db9be commit 4683644

File tree

8 files changed

+58
-23
lines changed

8 files changed

+58
-23
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
push:
55
branches:
6-
- 'master'
6+
- "main"
77
pull_request: {}
88

99
defaults:
@@ -15,21 +15,34 @@ jobs:
1515
name: Test PHP ${{ matrix.php }}
1616
runs-on: ubuntu-latest
1717
strategy:
18-
fail-fast: false
18+
fail-fast: true
1919
matrix:
20-
php: ['8.1', '8.2', '8.3']
20+
php: ["7.3", "7.4", "8.1", "8.2", "8.3"]
2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
- uses: shivammathur/setup-php@v2
2424
with:
2525
php-version: ${{ matrix.php }}
26-
tools: 'composer'
26+
tools: "composer"
27+
28+
- name: Cache Composer packages
29+
uses: actions/cache@v4
30+
with:
31+
path: vendor
32+
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-php-${{ matrix.php }}-
2735
2836
- name: Install dependencies
2937
run: |
30-
composer install
38+
composer install --prefer-dist --no-progress --no-interaction
3139
3240
- name: Lint and formatting
41+
if: >-
42+
matrix.php == '7.4' ||
43+
matrix.php == '8.1' ||
44+
matrix.php == '8.2' ||
45+
matrix.php == '8.3'
3346
run: |
3447
composer run-script format-check
3548

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"require-dev": {
1717
"friendsofphp/php-cs-fixer": "^2.15|^3.6",
18-
"phpunit/phpunit": "^10"
18+
"phpunit/phpunit": "^9"
1919
},
2020
"autoload": {
2121
"psr-4": {

lib/Resource/RoleResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
class RoleResponse
1111
{
12-
public string $slug;
12+
public $slug;
1313

1414
public function __construct(string $slug)
1515
{

lib/UserManagement.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function updateUser(
8989
$emailVerified = null,
9090
$password = null,
9191
$passwordHash = null,
92-
$passwordHashType = null,
92+
$passwordHashType = null
9393
) {
9494
$path = "user_management/users/{$userId}";
9595

@@ -304,7 +304,7 @@ public function listOrganizationMemberships(
304304
$limit = self::DEFAULT_PAGE_SIZE,
305305
$before = null,
306306
$after = null,
307-
$order = null,
307+
$order = null
308308
) {
309309
$path = "user_management/organization_memberships";
310310

@@ -1038,7 +1038,7 @@ public function getPasswordReset($passwordResetId)
10381038
* @return Resource\PasswordReset
10391039
*/
10401040
public function createPasswordReset(
1041-
$email,
1041+
$email
10421042
) {
10431043
$path = "user_management/password_reset";
10441044

@@ -1145,7 +1145,7 @@ public function getMagicAuth($magicAuthId)
11451145
*/
11461146
public function createMagicAuth(
11471147
$email,
1148-
$invitationToken = null,
1148+
$invitationToken = null
11491149
) {
11501150
$path = "user_management/magic_auth";
11511151

tests/WorkOS/ClientTest.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ class ClientTest extends TestCase
99
{
1010
use TestHelper;
1111

12-
#[DataProvider('requestExceptionTestProvider')]
12+
/**
13+
* @dataProvider requestExceptionTestProvider
14+
*/
1315
public function testClientThrowsRequestExceptions($statusCode, $exceptionClass)
1416
{
1517
$this->withApiKeyAndClientId();
@@ -31,7 +33,9 @@ public function testClientThrowsRequestExceptions($statusCode, $exceptionClass)
3133
Client::request(Client::METHOD_GET, $path);
3234
}
3335

34-
#[DataProvider('requestExceptionTestProvider')]
36+
/**
37+
* @dataProvider requestExceptionTestProvider
38+
*/
3539
public function testClientThrowsRequestExceptionsIncludeRequestId($statusCode, $exceptionClass)
3640
{
3741
$this->withApiKeyAndClientId();
@@ -60,7 +64,9 @@ public function testClientThrowsRequestExceptionsIncludeRequestId($statusCode, $
6064
$this->fail("Expected exception of type " . $exceptionClass . " not thrown.");
6165
}
6266

63-
#[DataProvider('requestExceptionTestProvider')]
67+
/**
68+
* @dataProvider requestExceptionTestProvider
69+
*/
6470
public function testClientThrowsRequestExceptionsWithBadMessage($statusCode, $exceptionClass)
6571
{
6672
$this->withApiKeyAndClientId();
@@ -87,7 +93,9 @@ public function testClientThrowsRequestExceptionsWithBadMessage($statusCode, $ex
8793
}
8894
}
8995

90-
#[DataProvider('requestExceptionTestProvider')]
96+
/**
97+
* @dataProvider requestExceptionTestProvider
98+
*/
9199
public function testClientThrowsRequestExceptionsWithMessageAndCode($statusCode, $exceptionClass)
92100
{
93101
$this->withApiKeyAndClientId();
@@ -116,7 +124,9 @@ public function testClientThrowsRequestExceptionsWithMessageAndCode($statusCode,
116124
}
117125
}
118126

119-
#[DataProvider('requestExceptionTestProvider')]
127+
/**
128+
* @dataProvider requestExceptionTestProvider
129+
*/
120130
public function testClientThrowsRequestExceptionsWithErrorAndErrorDescription($statusCode, $exceptionClass)
121131
{
122132
$this->withApiKeyAndClientId();
@@ -145,7 +155,9 @@ public function testClientThrowsRequestExceptionsWithErrorAndErrorDescription($s
145155
}
146156
}
147157

148-
#[DataProvider('requestExceptionTestProvider')]
158+
/**
159+
* @dataProvider requestExceptionTestProvider
160+
*/
149161
public function testClientThrowsRequestExceptionsWithErrors($statusCode, $exceptionClass)
150162
{
151163
$this->withApiKeyAndClientId();

tests/WorkOS/OrganizationsTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public function testCreateOrganizationWithDomainData()
7171

7272
$response = $this->organizations->createOrganization(
7373
"Organization Name",
74-
domain_data: array(["domain" => "example.com", "state" => "verified"]),
74+
null,
75+
null,
76+
null,
77+
array(["domain" => "example.com", "state" => "verified"]),
7578
);
7679
$this->assertSame($organization, $response->toArray());
7780
}
@@ -103,7 +106,10 @@ public function testUpdateOrganizationWithDomainData()
103106

104107
$response = $this->organizations->updateOrganization(
105108
"org_01EHQMYV6MBK39QC5PZXHY59C3",
106-
domain_data: array(["domain" => "example.com", "state" => "verified"]),
109+
null,
110+
null,
111+
null,
112+
array(["domain" => "example.com", "state" => "verified"]),
107113
);
108114
$this->assertSame($organization, $response->toArray());
109115
}

tests/WorkOS/SSOTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ protected function setUp(): void
2020
$this->sso = new SSO();
2121
}
2222

23-
#[DataProvider('authorizationUrlTestProvider')]
23+
/**
24+
* @dataProvider authorizationUrlTestProvider
25+
*/
2426
public function testAuthorizationURLExpectedParams(
2527
$domain,
2628
$redirectUri,

tests/WorkOS/UserManagementTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ public static function authorizationUrlTestDataProvider()
119119
];
120120
}
121121

122-
#[DataProvider('authorizationUrlTestDataProvider')]
122+
/**
123+
* @dataProvider authorizationUrlTestDataProvider
124+
*/
123125
public function testAuthorizationURLExpectedParams(
124126
$redirectUri,
125127
$state,
@@ -1240,7 +1242,7 @@ public function testGetLogoutUrl()
12401242

12411243
public function testGetLogoutUrlWithReturnTo()
12421244
{
1243-
$result = $this->userManagement->getLogoutUrl("session_123", return_to: "https://your-app.com");
1245+
$result = $this->userManagement->getLogoutUrl("session_123", "https://your-app.com");
12441246

12451247
$this->assertSame(
12461248
$result,

0 commit comments

Comments
 (0)