Skip to content

Fix deprecation notices in the backend module#1490

Open
austinderrick wants to merge 1 commit into
wintercms:developfrom
austinderrick:fix/php85-deprecations
Open

Fix deprecation notices in the backend module#1490
austinderrick wants to merge 1 commit into
wintercms:developfrom
austinderrick:fix/php85-deprecations

Conversation

@austinderrick

@austinderrick austinderrick commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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. TranscodeFilter is missing the return types declared by php_user_filter. Loading the class raises three deprecations on PHP 8.1+:

Deprecated: Return type of ...TranscodeFilter::filter($in, $out, &$consumed, $closing) should either be compatible with php_user_filter::filter($in, $out, &$consumed, bool $closing): int, or the #[\ReturnTypeWillChange] attribute should be used...
Deprecated: Return type of ...TranscodeFilter::onCreate() should either be compatible with php_user_filter::onCreate(): bool, ...
Deprecated: Return type of ...TranscodeFilter::onClose() should either be compatible with php_user_filter::onClose(): void, ...

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 into strtolower(). Lists::makeListColumn() and Filter::makeFilterScope() pass $config['type'] ?? null into displayAs(), and FormField, ListColumn, and FilterScope each do strtolower($type) ?: $this->type, so any column/scope/field config without an explicit type raises:

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated

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 develop checkout under PHP 8.5.5 with a small harness (load TranscodeFilter, call each displayAs(null)); after this change the same harness emits none. modules/backend PHPUnit 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

  • Bug Fixes

    • Improved null-safety for display/type selection in backend lists, forms, and filters to prevent errors when no render type is provided.
  • Refactor

    • Added nullable support for display/type parameters across backend UI components.
    • Declared explicit return and parameter types for backend filter lifecycle methods for clearer, more predictable behavior.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5530d117-b34f-42fd-9537-b6641bdb358f

📥 Commits

Reviewing files that changed from the base of the PR and between 7684a13 and b545a05.

📒 Files selected for processing (4)
  • modules/backend/behaviors/importexportcontroller/TranscodeFilter.php
  • modules/backend/classes/FilterScope.php
  • modules/backend/classes/FormField.php
  • modules/backend/classes/ListColumn.php
🚧 Files skipped from review as they are similar to previous changes (3)
  • modules/backend/classes/FilterScope.php
  • modules/backend/classes/FormField.php
  • modules/backend/classes/ListColumn.php

Walkthrough

This PR strengthens type safety across the backend by adding explicit return type declarations to the TranscodeFilter stream processor class and making three displayAs() configuration methods null-safe. TranscodeFilter's filter(), onCreate(), and onClose() methods now declare their return types (int, bool, and void respectively). FormField, FilterScope, and ListColumn displayAs() methods now accept nullable type parameters and apply null-coalescing before string operations, preventing errors when null or empty values are passed while preserving the existing type as a fallback.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective of the PR: fixing PHP 8.4/8.5 deprecation notices in the backend module through type declaration updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@austinderrick austinderrick force-pushed the fix/php85-deprecations branch from 7c28580 to 7684a13 Compare June 12, 2026 18:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7c28580 and 7684a13.

📒 Files selected for processing (4)
  • modules/backend/behaviors/importexportcontroller/TranscodeFilter.php
  • modules/backend/classes/FilterScope.php
  • modules/backend/classes/FormField.php
  • modules/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

Comment thread modules/backend/behaviors/importexportcontroller/TranscodeFilter.php Outdated
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.
@austinderrick austinderrick force-pushed the fix/php85-deprecations branch from 7684a13 to b545a05 Compare June 12, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant