Repository navigation
Turn a positioned block for rotate: 90deg on PHP 8 as on PHP 7 - #579
Merged
Merged
Conversation
jakejackson1
force-pushed
the
fix/552-rotate-angle
branch
2 times, most recently
from
September 29, 2026 22:54
e79cdb2 to
c1225aa
Compare
The positioned-block code compared the rotate value with == 90, -90 and 180. "90deg" == 90 is true on PHP 5.6 to 7.4 and false on PHP 8, so the same document turned the block on one and not the other. The angle is now read by Mpdf\Utils\Rotation::angle(), which tables already used as a private method: whole degrees, with or without "deg", wrapped to between -180 and 180, and kept only if the caller can draw it. A positioned block draws 90, -90 and 180, and a table 90 and -90, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jakejackson1
force-pushed
the
fix/552-rotate-angle
branch
from
September 29, 2026 23:45
c1225aa to
2bebe73
Compare
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mPDF's own
rotateproperty turns an absolutely or fixed positioned block. The block code checked the value with$p['ROTATE'] == 90 || == -90 || == 180.'90deg' == 90is true on PHP 5.6 to 7.4 and false on PHP 8, so.t { position: absolute; rotate: 90deg }was turned on PHP 7 and not on PHP 8. Unitless90,-90and180worked on both.Tables already read the same property through
Table::parseTableRotate(), which parses the angle. That parser came from mpdf#2178.The audit said
180"is accepted and never drawn". That is not so: the block code has a branch for it (mPDF 6), androtate: 180draws the block upside down on the base branch. So 180 stays supported for positioned blocks. The manual documents only90 | -90; tables never drew 180 and still do not.Part of #552 (Layout,
rotaterow in the audit). Part of #520.Change
Table::parseTableRotate()moves toMpdf\Utils\Rotation::angle($rotate, $supported). It reads whole degrees with or withoutdeg, wraps the angle to between -180 and 180, and returns it if the caller can draw it, or 0 if not.[90, -90], as before.[90, -90, 180], so90deg,-90deg,180deg,270degand-180degare read the same on every PHP version.The value is trimmed and
DEGis read case-insensitively. Tables otherwise behave as before.PHPStan now sees
$rotateas an int that is 90, -90, 180 or 0. That removes two false "might not be defined" reports each for$preroth,$prerotw,$rot_bposand$rot_rpos, and the baseline counts are lowered to match.Tests
PositionedBlockRotateTestrenders a positioned block for each of these values and reads which rotation matrices are drawn:90,90deg,-90,-90deg,270deg,-270deg,180,180deg,-180deg,45degandauto.PositionedBlockRotateSnapshotTest(positioned-block-rotate) puts six blocks beside captions saying which way each should be turned. The fixture was generated on PHP 8.5, which CI's snapshot job uses. On the base branch, the90deg,-90deg,270degand180degblocks are drawn unturned.With the source change reverted, the
degcases fail on PHP 8. No existing snapshot fixture changed.Checks
composer test: OK. 4468 tests, 31 skipped for missing optional packages or ungenerated data. The snapshot suite ran with Imagick and Ghostscript.composer cs: clean.🤖 Generated with Claude Code