Skip to content

fix(deps): add PHP 8.5 compatibility patch for mpdf/psr-http-message-shim#352

Open
superdav42 wants to merge 1 commit intomainfrom
fix/mpdf-php85-compatibility
Open

fix(deps): add PHP 8.5 compatibility patch for mpdf/psr-http-message-shim#352
superdav42 wants to merge 1 commit intomainfrom
fix/mpdf-php85-compatibility

Conversation

@superdav42
Copy link
Collaborator

@superdav42 superdav42 commented Mar 4, 2026

Summary

  • Fixes PHP 8.5 fatal error in mpdf/psr-http-message-shim package
  • Adds type declarations to Request class methods to match PSR-7 interface requirements

Problem

The mpdf/psr-http-message-shim package was written for PHP 5.6 and lacks type declarations. In PHP 8.x, the PSR-7 interfaces require strict type hints, causing this fatal error:

PHP Fatal error: Declaration of Mpdf\PsrHttpMessageShim\Request::getRequestTarget() must be compatible with Psr\Http\Message\RequestInterface::getRequestTarget(): string

Solution

Created a comprehensive patch that adds:

  • Return type declarations (:string, :array, :bool, etc.)
  • Parameter type hints (string $header, bool $preserveHost)
  • Interface return types (:RequestInterface, :MessageInterface, :StreamInterface)

Compatibility

  • ✅ PHP 7.4+ (all type hints use PHP 7.0+ features)
  • ✅ PHP 8.0-8.5
  • ✅ Automatically applied via composer patches plugin

Testing

  • PHP syntax validation passes
  • Request class instantiates correctly
  • All methods return expected types
  • Compatible with existing mpdf patches

Summary by CodeRabbit

  • Chores
    • Updated mPDF library dependency with PHP 8 compatibility enhancements through improved type declarations and strict typing to ensure better stability with modern PHP versions.

…shim

- Add type declarations to Request class methods to match PSR-7 interfaces
- Fixes fatal error: Declaration of getRequestTarget() must be compatible with RequestInterface::getRequestTarget(): string
- Patch adds return types and parameter types for all public methods
- Compatible with PHP 7.4+ (uses PHP 7.0+ type hint features)
- Automatically applied via composer patches plugin
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eb55bdbd-5342-4104-8beb-9500bb363a93

📥 Commits

Reviewing files that changed from the base of the PR and between fa58d9d and f36becd.

📒 Files selected for processing (2)
  • composer.json
  • patches/mpdf-psr-http-message-shim-php8-compat.patch

📝 Walkthrough

Walkthrough

A patch entry for the mpdf/psr-http-message-shim library is added to composer.json, enabling PHP 8 type hint compatibility through a dedicated patch file. The patch adds explicit scalar and object type declarations to the Request class public methods and return types without modifying runtime behavior.

Changes

Cohort / File(s) Summary
Composer Configuration
composer.json
Added patch entry for mpdf/psr-http-message-shim to enable PHP 8 compatibility.
PHP 8 Type Compatibility Patch
patches/mpdf-psr-http-message-shim-php8-compat.patch
Added explicit PHP 8 type hints and return types to Request class methods (getRequestTarget, withRequestTarget, getMethod, withMethod, getUri, withUri, getProtocolVersion, withProtocolVersion, getHeaders, hasHeader, getHeader, getHeaderLine, withHeader, withAddedHeader, withoutHeader, getBody, withBody). Return types reference PSR interfaces; parameter types enforced to string or object types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~18 minutes

Poem

🐰 Through vendor code hops our patch does leap,
PHP 8 types, promises to keep,
Request shall dance with hints so bright,
Type declarations make all right,
Compatibility's carrot, oh what delight! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a PHP 8.5 compatibility patch for the mpdf/psr-http-message-shim package to fix fatal errors from missing type declarations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mpdf-php85-compatibility

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

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