Fix PHP 8.4 deprecation: Add explicit nullable type hints#309
Merged
Conversation
Contributor
Greptile OverviewGreptile SummaryThis PR systematically resolves PHP 8.4 deprecation warnings by adding explicit nullable type hints ( Key Changes:
Implementation Quality:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant App as PHP Application
participant SDK as WorkOS SDK Methods
participant Client as Client::request()
participant Interface as RequestClientInterface
participant Curl as CurlRequestClient
participant API as WorkOS API
Note over App,SDK: Before PHP 8.4: Implicit nullable params
App->>SDK: createUser(email, null, null, ...)
Note over SDK: function createUser($email, $password = null)
Note over SDK: ⚠️ PHP 8.4 Deprecation Warning
Note over App,SDK: After Fix: Explicit nullable type hints
App->>SDK: createUser(email, null, null, ...)
Note over SDK: function createUser($email, ?string $password = null)
SDK->>Client: request(POST, path, null, params, true)
Note over Client: function request($method, $path, ?array $headers = null, ?array $params = null)
Client->>Interface: request(POST, url, null, params)
Note over Interface: Interface signature matches implementation
Interface->>Curl: request(POST, url, null, params)
Note over Curl: function request(..., ?array $headers = null, ?array $params = null)
Curl->>API: HTTP POST with JSON body
API-->>Curl: Response
Curl-->>Client: [result, headers, statusCode]
Client-->>SDK: Response data
SDK-->>App: Resource\User object
Note over App,API: ✅ No deprecation warnings in PHP 8.4
|
Resolves workos#296 PHP 8.4 deprecates implicitly nullable parameters (e.g., `string $param = null`). This change adds explicit nullable type hints (`?string $param = null`) across the SDK to eliminate deprecation warnings while maintaining backward compatibility with PHP 7.3+. Changes: - Added explicit nullable type hints to all nullable parameters in: - UserManagement, AuditLogs, Organizations, SSO, MFA, Portal, DirectorySync - Client, CurlRequestClient, WebhookResponse - Exception classes (GenericException, BaseRequestException) - Updated RequestClientInterface to match implementation signature - Added tests to verify null parameter handling and backward compatibility - Fixed test expectations to match actual implementation behavior All 167 tests pass. No breaking changes - only type hints added.
Take particular note of the changes to $roleSlugs. There was a mismatch between the phpdoc, tests, and api docs. This commit went with the array due to both the test and api doc specifying the array type. The php doc was updated to reflect the array change.
560a945 to
be83f58
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #296
PHP 8.4 deprecates implicitly nullable parameters (e.g.,
string $param = null). This change adds explicit nullable type hints (?string $param = null) across the SDK to eliminate deprecation warnings while maintaining backward compatibility with PHP 7.3+.Changes:
All 167 tests pass. No breaking changes - only type hints added.
Description
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.