Fixed deprecation notices in tests#300
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR addresses PHP 8.2+ deprecation notices by explicitly declaring class properties that were previously being created dynamically in test files. The changes affect 10 test files and one library file, with the primary focus being on resolving "Creation of dynamic property" deprecation warnings.
In the test files (WebhookTest.php, MFATest.php, WidgetsTest.php, DirectorySyncTest.php, OrganizationsTest.php, AuditLogsTest.php, PasswordlessTest.php, PortalTest.php, SSOTest.php, and UserManagementTest.php), the developer added explicit protected property declarations with proper PHPDoc type annotations. These properties were previously being assigned in setUp() methods without being declared, which triggers deprecation notices in PHP 8.2+. Each property is now properly typed (e.g., MFA, Widgets, DirectorySync, etc.) and follows consistent naming and documentation patterns.
The WebhookTest.php file received the most extensive changes, with seven properties being explicitly declared and an additional fix removing a deprecated utf8_decode() call that was replaced with direct assignment.
In the library file UserManagement.php, a type annotation improvement was made to the getLogoutUrl method. The $return_to parameter was updated from string to string|null in the PHPDoc and from string $return_to = null to ?string $return_to = null in the method signature, properly reflecting that this parameter is nullable.
These changes maintain full backward compatibility while ensuring the codebase adheres to modern PHP standards and runs without deprecation warnings on PHP 8.2+.
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it only adds property declarations and fixes type annotations
- Score reflects that these are standard modernization changes that improve PHP 8.2+ compatibility without altering functionality
- No files require special attention as all changes follow established patterns and best practices
11 files reviewed, no comments
nicknisi
left a comment
There was a problem hiding this comment.
These changes look good to me. After some checking, I think the removal of the utf8_decode call looks valid. Thanks for the fixes!
Description
The tests were throwing deprecation notices due to dynamic class properties being set. This PR resolves them by explicitly setting the properties.
Example of a notice that was thrown:
Deprecated: Creation of dynamic property WorkOS\WebhookTest::$payload is deprecatedDocumentation
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.