Skip to content

Scope all PSR libraries and remove PSR Log compatibility layers#1664

Draft
jakejackson1 wants to merge 1 commit into
developmentfrom
scope-all-psr-libraries
Draft

Scope all PSR libraries and remove PSR Log compatibility layers#1664
jakejackson1 wants to merge 1 commit into
developmentfrom
scope-all-psr-libraries

Conversation

@jakejackson1

@jakejackson1 jakejackson1 commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Prefixes every PSR library under GFPDF_Vendor via php-scoper so the plugin is fully self-contained and can no longer collide with other plugins that ship psr/log v2 or v3. This lets us delete the runtime PSR Log 1/2/3 compatibility layer entirely.

Changes

  • php-scoper config
    • Dropped the 'Psr\*' whitelist from tools/php-scoper/config/monolog.php so Monolog's PSR references get prefixed to GFPDF_Vendor\Psr\*.
    • Removed the tools/php-scoper/config/mpdf.php patcher that stripped the prefix back off LoggerInterface in the mPDF logger-aware traits.
  • Removed the PSR Log 1/2/3 compatibility layer
    • Deleted src/Helper/Log/MonoLoggerPsrLog2And3.php (the v2/v3 proxy).
    • Stripped Logger::get_monolog()'s runtime version probe and class_alias bridging; setup_logger() now instantiates Monolog directly.
    • Deleted the obsolete Test_MonoLoggerPsrLog2And3.php and updated Test_Logger.php.
  • Type hints — all 28 use Psr\Log\LoggerInterface; statements in src/ now use use GFPDF_Vendor\Psr\Log\LoggerInterface;.

Verification

  • Regenerated vendor_prefixed/ via composer install + composer prefix; confirmed Monolog and the mPDF traits consistently reference GFPDF_Vendor\Psr\Log\* and the autoloader maps the prefixed classes.
  • Full PHP suite green: 1513 tests, 4862 assertions, 17 pre-existing skips. The PDF-generation path (mPDF setLogger ← the prefixed logger) passes.
  • PHPCS clean on the changed source.

Dependent add-on PRs

Removing the unprefixed \Psr\Log shim means add-ons that type-hinted the logger against the plain interface now receive a scoped logger that no longer satisfies that hint. These companion PRs decouple each add-on's logger boundary so they work against both this (scoped) core and older (unprefixed) releases. They should land alongside this PR:

  • GravityPDF/gravity-pdf-bulk-generator#201 — untype $log in SessionId / ZipPath
  • GravityPDF/pdf-for-gravityview#88 — untype $log in PdfEmail
  • GravityPDF/gravity-pdf-images#2 — untype $log in DoesTemplateHaveGroup + test logger
  • GravityPDF/gravity-pdf-for-wpml#16 — test logger via GPDFAPI::get_log_class()
  • GravityPDF/gravity-pdf-core-booster#125 — remove dead Monolog\Logger imports

An org-wide audit of the remaining ~30 dependent repos found no other add-on type-hinting the logger boundary (most consume it only via Helper_Trait_Logger + duck-typed calls, which is unaffected).

Notes

psr/container is only a dev-time transitive dependency of php-scoper's own Symfony components and isn't referenced by any production package, so it's intentionally left out of scoping (it won't ship in the --no-dev release build).

🤖 Generated with Claude Code

Prefix every PSR library under GFPDF_Vendor via php-scoper so the plugin
is fully self-contained and can no longer collide with other plugins that
ship psr/log v2 or v3.

- php-scoper: drop the `Psr\*` whitelist from the Monolog config so its
  PSR references get prefixed, and remove the mpdf patcher that stripped
  the prefix back off LoggerInterface in the logger-aware traits.
- Remove the runtime PSR Log 1/2/3 compatibility layer: delete the
  MonoLoggerPsrLog2And3 proxy and Logger::get_monolog()'s version probe
  and class_alias bridging; setup_logger() now instantiates Monolog
  directly.
- Update all type hints to the prefixed GFPDF_Vendor\Psr\Log\LoggerInterface.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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