Fix PHP 8.4 deprecation in AbstractStrlen::substr()#161
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/Rule/AbstractStrlen.php (1)
141-141: Consider updating test helper classes for consistency.While the test helper classes in
tests/Rule/FakeStrlen*.phpwon't trigger deprecation warnings (they use no parameter type hints), you may want to update theirsubstr()method signatures to match the parent class for consistency:public function substr(string $str, int $start, ?int $length = null): stringThis is purely optional and doesn't affect functionality.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Rule/AbstractStrlen.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Rule/AbstractStrlen.php (3)
tests/Rule/FakeStrlen.php (1)
substr(21-24)tests/Rule/FakeStrlenIconv.php (1)
substr(16-19)tests/Rule/FakeStrlenMbstring.php (1)
substr(16-19)
🔇 Additional comments (1)
src/Rule/AbstractStrlen.php (1)
141-141: LGTM! Correctly addresses PHP 8.4 deprecation.The change from
int $length = nullto?int $length = nullproperly fixes the PHP 8.4 deprecation warning for implicitly nullable parameters. This explicit nullable syntax is the recommended approach and maintains full backward compatibility while removing the warning.
Fix deprecation warning by explicitly marking the $length parameter as nullable (?int) in AbstractStrlen::substr() method.
Summary by CodeRabbit