Skip to content

Commit

Permalink
Some strict checks
Browse files Browse the repository at this point in the history
  • Loading branch information
finwe committed Sep 1, 2023
1 parent 69be907 commit c8867f7
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/Mpdf.php
Expand Up @@ -1639,11 +1639,9 @@ function _setPageSize($format, &$orientation)
}

// e.g. A4-L = A4 landscape, A4-P = A4 portrait
$orientation = $orientation ?: 'P';
if (preg_match('/([0-9a-zA-Z]*)-([P,L])/i', $format, $m)) {
$format = $m[1];
$orientation = $m[2];
} elseif (empty($orientation)) {
$orientation = 'P';
list(, $format, $orientation) = $m;
}

$format = PageFormat::getSizeFromName($format);
Expand All @@ -1666,11 +1664,11 @@ function _setPageSize($format, &$orientation)

// Page orientation
$orientation = strtolower($orientation);
if ($orientation === 'p' || $orientation == 'portrait') {
if ($orientation === 'p' || $orientation === 'portrait') {
$orientation = 'P';
$this->wPt = $this->fwPt;
$this->hPt = $this->fhPt;
} elseif ($orientation === 'l' || $orientation == 'landscape') {
} elseif ($orientation === 'l' || $orientation === 'landscape') {
$orientation = 'L';
$this->wPt = $this->fhPt;
$this->hPt = $this->fwPt;
Expand Down Expand Up @@ -10150,6 +10148,7 @@ function _beginpage(
$this->page++;
$this->pages[$this->page] = '';
}

$this->state = 2;
$resetHTMLHeadersrequired = false;

Expand All @@ -10161,13 +10160,13 @@ function _beginpage(
// Paged media (page-box)
if ($pagesel || $this->page_box['using']) {

if ($pagesel || $this->page == 1) {
if ($pagesel || $this->page === 1) {
$first = true;
} else {
$first = false;
}

if ($this->mirrorMargins && ($this->page % 2 == 0)) {
if ($this->mirrorMargins && ($this->page % 2 === 0)) {
$oddEven = 'E';
} else {
$oddEven = 'O';
Expand All @@ -10183,7 +10182,7 @@ function _beginpage(

list($orientation, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $hname, $fname, $bg, $resetpagenum, $pagenumstyle, $suppress, $marks, $newformat) = $this->SetPagedMediaCSS($psel, $first, $oddEven);

if ($this->mirrorMargins && ($this->page % 2 == 0)) {
if ($this->mirrorMargins && ($this->page % 2 === 0)) {

if ($hname) {
$ehvalue = 1;
Expand Down Expand Up @@ -10266,15 +10265,15 @@ function _beginpage(
}
}

if ($orientation != $this->CurOrientation || $newformat) {
if ($orientation !== $this->CurOrientation || $newformat) {

// Change orientation
if ($orientation == 'P') {
if ($orientation === 'P') {
$this->wPt = $this->fwPt;
$this->hPt = $this->fhPt;
$this->w = $this->fw;
$this->h = $this->fh;
if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation == 'P') {
if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation === 'P') {
$this->tMargin = $this->orig_tMargin;
$this->bMargin = $this->orig_bMargin;
$this->DeflMargin = $this->orig_lMargin;
Expand All @@ -10290,7 +10289,7 @@ function _beginpage(
$this->w = $this->fh;
$this->h = $this->fw;

if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation == 'P') {
if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation === 'P') {
$this->tMargin = $this->orig_lMargin;
$this->bMargin = $this->orig_rMargin;
$this->DeflMargin = $this->orig_bMargin;
Expand Down

0 comments on commit c8867f7

Please sign in to comment.