Skip to content

Commit

Permalink
Merge pull request #4 from magento-gl/fixes-magento2-issue-37897
Browse files Browse the repository at this point in the history
Fixed regression from fixing PHP 8.2 deprecated usages earlier, which broke rendering certain elements in a pdf in Magento
  • Loading branch information
sidolov authored Aug 25, 2023
2 parents 243d76f + 6047a4a commit 4426cdf
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 11 deletions.
12 changes: 1 addition & 11 deletions library/Zend/Pdf/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ abstract class Zend_Pdf_Element
*/
private $_parentObject = null;

/**
* Object value
*
* @var string
*/
public $value;

/**
* Return type of the element.
* See ZPdfPDFConst for possible values
Expand Down Expand Up @@ -138,10 +131,7 @@ public function cleanUp()
*
* @return mixed
*/
public function toPhp()
{
return $this->value;
}
abstract public function toPhp();

/**
* Convert PHP value into PDF element.
Expand Down
19 changes: 19 additions & 0 deletions library/Zend/Pdf/Element/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
*/
class Zend_Pdf_Element_Boolean extends Zend_Pdf_Element
{
/**
* Object value
*
* @var boolean
*/
public $value;


/**
* Object constructor
*
Expand Down Expand Up @@ -72,4 +80,15 @@ public function toString($factory = null)
{
return $this->value ? 'true' : 'false';
}


/**
* Convert PDF element to PHP type.
*
* @return boolean
*/
public function toPhp()
{
return $this->value;
}
}
19 changes: 19 additions & 0 deletions library/Zend/Pdf/Element/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
*/
class Zend_Pdf_Element_Name extends Zend_Pdf_Element
{
/**
* Object value
*
* @var string
*/
public $value;


/**
* Object constructor
*
Expand Down Expand Up @@ -150,4 +158,15 @@ public function toString($factory = null)
{
return '/' . self::escape((string)$this->value);
}


/**
* Convert PDF element to PHP type.
*
* @return string
*/
public function toPhp()
{
return $this->value;
}
}
19 changes: 19 additions & 0 deletions library/Zend/Pdf/Element/Null.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
*/
class Zend_Pdf_Element_Null extends Zend_Pdf_Element
{
/**
* Object value. Always null.
*
* @var mixed
*/
public $value;


/**
* Object constructor
*/
Expand Down Expand Up @@ -64,4 +72,15 @@ public function toString($factory = null)
{
return 'null';
}


/**
* Convert PDF element to PHP type.
*
* @return mixed
*/
public function toPhp()
{
return $this->value;
}
}
19 changes: 19 additions & 0 deletions library/Zend/Pdf/Element/Numeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
*/
class Zend_Pdf_Element_Numeric extends Zend_Pdf_Element
{
/**
* Object value
*
* @var numeric
*/
public $value;


/**
* Object constructor
*
Expand Down Expand Up @@ -84,4 +92,15 @@ public function toString($factory = null)
}
return sprintf("%.{$prec}F", $this->value);
}


/**
* Convert PDF element to PHP type.
*
* @return numeric
*/
public function toPhp()
{
return $this->value;
}
}
18 changes: 18 additions & 0 deletions library/Zend/Pdf/Element/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
*/
class Zend_Pdf_Element_Stream extends Zend_Pdf_Element
{
/**
* Object value
*
* @var Zend_Memory_Container
*/
public $value;


/**
* Object constructor
*
Expand Down Expand Up @@ -119,4 +127,14 @@ public function toString($factory = null)
{
return "stream\n" . $this->value->getRef() . "\nendstream";
}

/**
* Convert PDF element to PHP type.
*
* @return Zend_Memory_Container
*/
public function toPhp()
{
return $this->value;
}
}
18 changes: 18 additions & 0 deletions library/Zend/Pdf/Element/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
*/
class Zend_Pdf_Element_String extends Zend_Pdf_Element
{
/**
* Object value
*
* @var string
*/
public $value;

/**
* Object constructor
*
Expand Down Expand Up @@ -67,6 +74,17 @@ public function toString($factory = null)
}


/**
* Convert PDF element to PHP type.
*
* @return string
*/
public function toPhp()
{
return $this->value;
}


/**
* Escape string according to the PDF rules
*
Expand Down

0 comments on commit 4426cdf

Please sign in to comment.