php-sip
php-sip copied to clipboard
Refactor code for PHP 8.4 compatibility
Refactor code for PHP 8.4 compatibility
Summary
Fixed the main PHP 8.4 compatibility issue by adding explicit nullable type declarations to method parameters that previously used implicit nullable syntax (deprecated in PHP 8.4).
Changes made:
- Updated
PhpSIP::__construct()to use?string $src_ip = null, ?int $src_port = null, ?int $fr_timer = null - Updated
PhpSIP::setContentType()to use?string $content_type = null - Updated
PhpSIP::setCallId()to use?string $v = null
Validation completed:
- ✅ Syntax validation with PHP 8.4.10 - no errors detected
- ✅ Automated search found and fixed all instances of implicitly nullable parameters
- ⚠️ Limited functional testing due to network requirements
Review & Testing Checklist for Human
- [ ] Verify type declarations are semantically correct - Confirm that IP addresses should be strings, ports/timers should be integers
- [ ] Test with actual SIP infrastructure - Run examples against real SIP servers to ensure functionality isn't broken
- [ ] Check for other PHP 8.4 compatibility issues - Review for any other deprecated features I may have missed
- [ ] Validate backward compatibility - Ensure existing code using this library still works without modifications
Recommended test plan: Run your existing SIP test suite or example scripts against a real SIP server with PHP 8.4 to verify end-to-end functionality.
Diagram
%%{ init : { "theme" : "default" }}%%
graph TD
Examples["examples/*.php<br/>(message.php, options.php, etc)"]:::context
Main["PhpSIP.class.php<br/>(Main SIP library)"]:::major-edit
Exception["PhpSIP.Exception.php<br/>(Exception class)"]:::context
Examples -->|"require_once"| Main
Main -->|"throws"| Exception
Main -->|"Updated constructor<br/>and method signatures"| TypeHints["Explicit nullable types<br/>?string, ?int"]:::major-edit
subgraph Legend
L1["Major Edit"]:::major-edit
L2["Minor Edit"]:::minor-edit
L3["Context/No Edit"]:::context
end
classDef major-edit fill:#90EE90
classDef minor-edit fill:#87CEEB
classDef context fill:#FFFFFF
Notes
- This addresses the main PHP 8.4 deprecation affecting this codebase (implicitly nullable parameters)
- Socket functions and regex patterns used in the library remain compatible with PHP 8.4
- Link to Devin run: https://app.devin.ai/sessions/765f7395244241abbbdf2dc2516f7015
- Requested by: @l7s
🤖 Devin AI Engineer
I'll be helping with this pull request! Here's what you should know:
✅ I will automatically:
- Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
- Look at CI failures and help fix them
Note: I can only respond to comments from users who have write access to this repository.
⚙️ Control Options:
- [ ] Disable automatic comment and CI monitoring