Fix deprecation notices in the backend module#1490
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThis PR updates backend method signatures and default type handling. TranscodeFilter now declares explicit return types and a typed closing parameter. FilterScope, FormField, and ListColumn now require string type arguments in displayAs(). Filter, Form, and Lists now default missing type values to strings, and Form::makeFormField() now rejects non-string resolved types. Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
7c28580 to
7684a13
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@modules/backend/behaviors/importexportcontroller/TranscodeFilter.php`:
- Line 20: The filter method signature in TranscodeFilter::filter must match the
php_user_filter parent by adding the missing bool type hint for the fourth
parameter; update the method declaration from filter($in, $out, &$consumed,
$closing): int to include bool $closing so it reads filter($in, $out,
&$consumed, bool $closing): int, ensuring the parameter type aligns with the
parent and any callers remain compatible.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dae7d38b-7200-4ba8-969d-ac7595131222
📒 Files selected for processing (4)
modules/backend/behaviors/importexportcontroller/TranscodeFilter.phpmodules/backend/classes/FilterScope.phpmodules/backend/classes/FormField.phpmodules/backend/classes/ListColumn.php
🚧 Files skipped from review as they are similar to previous changes (2)
- modules/backend/classes/ListColumn.php
- modules/backend/classes/FilterScope.php
TranscodeFilter was missing the return types declared (tentatively) by php_user_filter, and the three displayAs() implementations passed a null render mode straight into strtolower(). Both raise deprecation notices on modern PHP.
7684a13 to
b545a05
Compare
Per review (option 2): FilterScope, FormField and ListColumn displayAs() now require a non-null string $type, and the Filter/Form/Lists builders default a missing config 'type' to the class default (group/text) instead of passing null. Callers that pass null now fail fast rather than being silently coerced to the default.
Summary
Fixes two families of deprecation notices in the backend module, found while auditing PHP 8.4/8.5 readiness (follow-up to #1489):
1.
TranscodeFilteris missing the return types declared byphp_user_filter. Loading the class raises three deprecations on PHP 8.1+:Since the repo's PHP floor is 8.1, this adds the real return types (
: int,: bool,: void) rather than#[\ReturnTypeWillChange]. The existing bodies already return the right types (PSFS_PASS_ON, booleans, nothing).2.
displayAs()passes a null render mode intostrtolower().Lists::makeListColumn()andFilter::makeFilterScope()pass$config['type'] ?? nullintodisplayAs(), andFormField,ListColumn, andFilterScopeeach dostrtolower($type) ?: $this->type, so any column/scope/field config without an explicittyperaises:Fixed by typing the parameter natively (
?string $type) in all three classes and coalescing inside (strtolower($type ?? '')), keeping identical semantics: null and''both fall back to the existing type. Real argument types rather than a docblock-only change, per the direction from the storm#229 review. All in-repo callers already pass string-or-null (Form::makeFormField()validates the type before calling), and untyped subclass overrides remain legal (widening).Verification
Reproduced all four deprecations on a clean
developcheckout under PHP 8.5.5 with a small harness (loadTranscodeFilter, call eachdisplayAs(null)); after this change the same harness emits none.modules/backendPHPUnit suite shows an identical result before and after the change on the same machine (the handful of locally-failing tests are environment-related and untouched by this diff: FileUploadScoping, NavigationManager, WidgetManager).Summary by CodeRabbit