8000 Add type declaration to paper-orientation parameters by Mellthas · Pull Request #3060 · dompdf/dompdf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add type declaration to paper-orientation parameters #3060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Adapter/CPDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class CPDF implements Canvas
*/
protected $_current_opacity = 1;

public function __construct($paper = "letter", $orientation = "portrait", ?Dompdf $dompdf = null)
public function __construct($paper = "letter", string $orientation = "portrait", ?Dompdf $dompdf = null)
{
if (is_array($paper)) {
$size = array_map("floatval", $paper);
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/GD.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class GD implements Canvas
/**
* Background color array
*
* @var int
* @var array
*/
protected $_bg_color_array;

Expand All @@ -131,11 +131,11 @@ class GD implements Canvas
* @param string|float[] $paper The paper size to use as either a standard paper size (see {@link CPDF::$PAPER_SIZES}) or
* an array of the form `[x1, y1, x2, y2]` (typically `[0, 0, width, height]`).
* @param string $orientation The paper orientation, either `portrait` or `landscape`.
* @param Dompdf $dompdf The Dompdf instance.
* @param Dompdf|null $dompdf The Dompdf instance.
* @param float $aa_factor Anti-aliasing factor, 1 for no AA
* @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1
*/
public function __construct($paper = "letter", $orientation = "portrait", ?Dompdf $dompdf = null, $aa_factor = 1.0, $bg_color = [1, 1, 1, 0])
public function __construct($paper = "letter", string $orientation = "portrait", ?Dompdf $dompdf = null, float $aa_factor = 1.0, array $bg_color = [1, 1, 1, 0])
{
if (is_array($paper)) {
$size = array_map("floatval", $paper);
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/PDFLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class PDFLib implements Canvas
*/
protected $_pages;

public function __construct($paper = "letter", $orientation = "portrait", ?Dompdf $dompdf = null)
public function __construct($paper = "letter", string $orientation = "portrait", ?Dompdf $dompdf = null)
{
if (is_array($paper)) {
$size = array_map("floatval", $paper);
Expand Down
4 changes: 2 additions & 2 deletions src/Canvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ interface Canvas
* @param string|float[] $paper The paper size to use as either a standard paper size (see {@link Dompdf\Adapter\CPDF::$PAPER_SIZES})
* or an array of the form `[x1, y1, x2, y2]` (typically `[0, 0, width, height]`).
* @param string $orientation The paper orientation, either `portrait` or `landscape`.
* @param Dompdf $dompdf The Dompdf instance.
* @param Dompdf|null $dompdf The Dompdf instance.
*/
public function __construct($paper = "letter", $orientation = "portrait", ?Dompdf $dompdf = null);
public function __construct($paper = "letter", string $orientation = "portrait", ?Dompdf $dompdf = null);

/**
* @return Dompdf
Expand Down
10 changes: 5 additions & 5 deletions src/CanvasFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ private function __construct()
}

/**
* @param Dompdf $dompdf
* @param string|array $paper
* @param string $orientation
* @param string $class
* @param Dompdf $dompdf
* @param string|float[] $paper
* @param string $orientation
* @param string|null $class
*
* @return Canvas
*/
static function get_instance(Dompdf $dompdf, $paper = null, $orientation = null, $class = null)
static function get_instance(Dompdf $dompdf, $paper, string $orientation, ?string $class = null)
{
$backend = strtolower($dompdf->getOptions()->getPdfBackend());

Expand Down
8 changes: 4 additions & 4 deletions src/Dompdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Dompdf
/**
* Desired paper size ('letter', 'legal', 'A4', etc.)
*
* @var string|array
* @var string|float[]
*/
private $paperSize;

Expand Down Expand Up @@ -965,7 +965,7 @@ public function set_paper($size, $orientation = "portrait")
* @param string $orientation 'portrait' or 'landscape'
* @return $this
*/
public function setPaper($size, $orientation = "portrait")
public function setPaper($size, string $orientation = "portrait"): self
{
$this->paperSize = $size;
$this->paperOrientation = $orientation;
Expand All @@ -977,7 +977,7 @@ public function setPaper($size, $orientation = "portrait")
*
* @return float[] A four-element float array
*/
public function getPaperSize()
public function getPaperSize(): array
{
$paper = $this->paperSize;
$orientation = $this->paperOrientation;
Expand All @@ -1001,7 +1001,7 @@ public function getPaperSize()
*
* @return string Either "portrait" or "landscape"
*/
public function getPaperOrientation()
public function getPaperOrientation(): string
{
return $this->paperOrientation;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Options
* North America standard is "letter"; other countries generally "a4"
* @see \Dompdf\Adapter\CPDF::PAPER_SIZES for valid sizes
*
* @var string
* @var string|float[]
*/
private $defaultPaperSize = "letter";

Expand Down Expand Up @@ -789,10 +789,10 @@ public function getDefaultMediaType()
}

/**
* @param string $defaultPaperSize
* @param string|float[] $defaultPaperSize
* @return $this
*/
public function setDefaultPaperSize($defaultPaperSize)
public function setDefaultPaperSize($defaultPaperSize): self
{
$this->defaultPaperSize = $defaultPaperSize;
return $this;
Expand All @@ -802,14 +802,14 @@ public function setDefaultPaperSize($defaultPaperSize)
* @param string $defaultPaperOrientation
* @return $this
*/
public function setDefaultPaperOrientation($defaultPaperOrientation)
public function setDefaultPaperOrientation(string $defaultPaperOrientation): self
{
$this->defaultPaperOrientation = $defaultPaperOrientation;
return $this;
}

/**
* @return string
* @return string|float[]
*/
public function getDefaultPaperSize()
{
Expand All @@ -819,7 +819,7 @@ public function getDefaultPaperSize()
/**
* @return string
*/
public function getDefaultPaperOrientation()
public function getDefaultPaperOrientation(): string
{
return $this->defaultPaperOrientation;
}
Expand Down
0