Skip to content
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

Make framework PHP 7.4 compatible #16

Merged
merged 4 commits into from
Dec 16, 2019
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
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4snapshot
allow_failures:
- php: 7.4snapshot
- php: 7.4
fast_finish: true

env:
Expand Down
27 changes: 16 additions & 11 deletions packages/zend-amf/library/Zend/Amf/Parse/Amf0/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
* Check if the given object is in the reference table, write the reference if it exists,
* otherwise add the object to the reference table
*
* @param mixed $object object reference to check for reference
* @param mixed $object object reference to check for reference
* @param string $markerType AMF type of the object to write
* @param mixed $objectByVal object to check for reference
* @param mixed $objectByVal object to check for reference
* @throws Zend_Amf_Exception
* @return Boolean true, if the reference was written, false otherwise
*/
protected function writeObjectReference(&$object, $markerType, $objectByVal = false)
Expand Down Expand Up @@ -221,15 +222,16 @@ protected function writeObjectReference(&$object, $markerType, $objectByVal = fa
/**
* Write a PHP array with string or mixed keys.
*
* @param object $data
* @param $object
* @throws Zend_Amf_Exception
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeObject($object)
{
// Loop each element and write the name of the property.
foreach ($object as $key => &$value) {
// skip variables starting with an _ private transient
if( $key[0] == "_") continue;
if(is_string($key) && strpos($key, '_') === 0) continue;
$this->_stream->writeUTF($key);
$this->writeTypeMarker($value);
}
Expand All @@ -245,12 +247,13 @@ public function writeObject($object)
* is encountered call writeTypeMarker with mixed array.
*
* @param array $array
* @throws Zend_Amf_Exception
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeArray(&$array)
{
$length = count($array);
if (!$length < 0) {
if ($length === 0) {
// write the length of the array
$this->_stream->writeLong(0);
} else {
Expand All @@ -267,7 +270,8 @@ public function writeArray(&$array)
/**
* Convert the DateTime into an AMF Date
*
* @param DateTime|Zend_Date $data
* @param DateTime|Zend_Date $data
* @throws Zend_Amf_Exception
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeDate($data)
Expand All @@ -294,7 +298,8 @@ public function writeDate($data)
/**
* Write a class mapped object to the output stream.
*
* @param object $data
* @param object $data
* @throws Zend_Amf_Exception
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeTypedObject($data)
Expand All @@ -308,7 +313,8 @@ public function writeTypedObject($data)
* Encountered and AMF3 Type Marker use AMF3 serializer. Once AMF3 is
* encountered it will not return to AMf0.
*
* @param string $data
* @param string $data
* @throws Zend_Amf_Exception
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeAmf3TypeMarker(&$data)
Expand All @@ -330,7 +336,6 @@ protected function getClassName($object)
{
// require_once 'Zend/Amf/Parse/TypeLoader.php';
//Check to see if the object is a typed object and we need to change
$className = '';
switch (true) {
// the return class mapped name back to actionscript class name.
case Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object)):
Expand All @@ -350,10 +355,10 @@ protected function getClassName($object)
break;
// By default, use object's class name
default:
$className = get_class($object);
$className = get_class($object);
break;
}
if(!$className == '') {
if($className !== '') {
return $className;
} else {
return false;
Expand Down
16 changes: 11 additions & 5 deletions packages/zend-amf/library/Zend/Amf/Util/BinaryStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class Zend_Amf_Util_BinaryStream
* by the methods in the class. Detect if the class should use big or
* little Endian encoding.
*
* @param string $stream use '' if creating a new stream or pass a string if reading.
* @param string $stream use '' if creating a new stream or pass a string if reading.
* @throws Zend_Amf_Exception
* @return void
*/
public function __construct($stream)
Expand Down Expand Up @@ -140,7 +141,7 @@ public function readByte()
);
}

return ord($this->_stream{$this->_needle++});
return ord($this->_stream[$this->_needle++]);
}

/**
Expand All @@ -158,6 +159,7 @@ public function writeByte($stream)
/**
* Reads a signed 32-bit integer from the data stream.
*
* @throws Zend_Amf_Exception
* @return int Value is in the range of -2147483648 to 2147483647
*/
public function readInt()
Expand All @@ -180,6 +182,7 @@ public function writeInt($stream)
/**
* Reads a UTF-8 string from the data stream
*
* @throws Zend_Amf_Exception
* @return string A UTF-8 string produced by the byte representation of characters
*/
public function readUtf()
Expand All @@ -205,6 +208,7 @@ public function writeUtf($stream)
/**
* Read a long UTF string
*
* @throws Zend_Amf_Exception
* @return string
*/
public function readLongUtf()
Expand All @@ -216,8 +220,8 @@ public function readLongUtf()
/**
* Write a long UTF string to the buffer
*
* @param string $stream
* @return Zend_Amf_Util_BinaryStream
* @param string $stream
* @return void
*/
public function writeLongUtf($stream)
{
Expand All @@ -228,6 +232,7 @@ public function writeLongUtf($stream)
/**
* Read a long numeric value
*
* @throws Zend_Amf_Exception
* @return double
*/
public function readLong()
Expand All @@ -249,8 +254,9 @@ public function writeLong($stream)

/**
* Read a 16 bit unsigned short.
*
* @todo This could use the unpack() w/ S,n, or v
*
* @throws Zend_Amf_Exception
* @return double
*/
public function readUnsignedShort()
Expand Down
6 changes: 4 additions & 2 deletions packages/zend-barcode/library/Zend/Barcode/Object/Code25.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected function _calculateBarcodeWidth()

/**
* Partial check of interleaved 2 of 5 barcode
* @throws Zend_Barcode_Object_Exception
* @return void
*/
protected function _checkParams()
Expand Down Expand Up @@ -122,7 +123,8 @@ protected function _prepareBarcode()
/**
* Get barcode checksum
*
* @param string $text
* @param string $text
* @throws Zend_Barcode_Object_Exception
* @return int
*/
public function getChecksum($text)
Expand All @@ -132,7 +134,7 @@ public function getChecksum($text)
$checksum = 0;

for ($i = strlen($text); $i > 0; $i --) {
$checksum += intval($text{$i - 1}) * $factor;
$checksum += (int)$text[$i - 1] * $factor;
$factor = 4 - $factor;
}

Expand Down
21 changes: 11 additions & 10 deletions packages/zend-barcode/library/Zend/Barcode/Object/Ean13.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ class Zend_Barcode_Object_Ean13 extends Zend_Barcode_Object_ObjectAbstract
*/
protected $_codingMap = array(
'A' => array(
0 => "0001101", 1 => "0011001", 2 => "0010011", 3 => "0111101", 4 => "0100011",
5 => "0110001", 6 => "0101111", 7 => "0111011", 8 => "0110111", 9 => "0001011"
0 => '0001101', 1 => '0011001', 2 => '0010011', 3 => '0111101', 4 => '0100011',
5 => '0110001', 6 => '0101111', 7 => '0111011', 8 => '0110111', 9 => '0001011'
),
'B' => array(
0 => "0100111", 1 => "0110011", 2 => "0011011", 3 => "0100001", 4 => "0011101",
5 => "0111001", 6 => "0000101", 7 => "0010001", 8 => "0001001", 9 => "0010111"
0 => '0100111', 1 => '0110011', 2 => '0011011', 3 => '0100001', 4 => '0011101',
5 => '0111001', 6 => '0000101', 7 => '0010001', 8 => '0001001', 9 => '0010111'
),
'C' => array(
0 => "1110010", 1 => "1100110", 2 => "1101100", 3 => "1000010", 4 => "1011100",
5 => "1001110", 6 => "1010000", 7 => "1000100", 8 => "1001000", 9 => "1110100"
0 => '1110010', 1 => '1100110', 2 => '1101100', 3 => '1000010', 4 => '1011100',
5 => '1001110', 6 => '1010000', 7 => '1000100', 8 => '1001000', 9 => '1110100'
));

protected $_parities = array(
Expand Down Expand Up @@ -156,7 +156,8 @@ protected function _prepareBarcode()
/**
* Get barcode checksum
*
* @param string $text
* @param string $text
* @throws Zend_Barcode_Object_Exception
* @return int
*/
public function getChecksum($text)
Expand All @@ -166,7 +167,7 @@ public function getChecksum($text)
$checksum = 0;

for ($i = strlen($text); $i > 0; $i --) {
$checksum += intval($text{$i - 1}) * $factor;
$checksum += (int)$text[$i - 1] * $factor;
$factor = 4 - $factor;
}

Expand Down Expand Up @@ -196,7 +197,7 @@ protected function _drawEan13Text()
$leftPosition = $this->getQuietZone() - $characterWidth;
for ($i = 0; $i < $this->_barcodeLength; $i ++) {
$this->_addText(
$text{$i},
$text[$i],
$this->_fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
Expand All @@ -218,7 +219,7 @@ protected function _drawEan13Text()
default:
$factor = 0;
}
$leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
$leftPosition += $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/zend-barcode/library/Zend/Barcode/Object/Ean5.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ protected function _prepareBarcode()
/**
* Get barcode checksum
*
* @param string $text
* @param string $text
* @throws Zend_Barcode_Object_Exception
* @return int
*/
public function getChecksum($text)
Expand All @@ -124,7 +125,7 @@ public function getChecksum($text)
$checksum = 0;

for ($i = 0 ; $i < $this->_barcodeLength; $i ++) {
$checksum += intval($text{$i}) * ($i % 2 ? 9 : 3);
$checksum += (int)$text[$i] * (($i % 2) ? 9 : 3);
}

return ($checksum % 10);
Expand Down
7 changes: 4 additions & 3 deletions packages/zend-barcode/library/Zend/Barcode/Object/Ean8.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function _drawText()
$leftPosition = $this->getQuietZone() + (3 * $this->_barThinWidth) * $this->_factor;
for ($i = 0; $i < $this->_barcodeLength; $i ++) {
$this->_addText(
$text{$i},
$text[$i],
$this->_fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
Expand All @@ -142,7 +142,7 @@ protected function _drawText()
default:
$factor = 0;
}
$leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
$leftPosition += $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
}
}
}
Expand All @@ -152,8 +152,9 @@ protected function _drawText()
* (to suppress checksum character substitution)
*
* @param string $value
* @param array $options
* @param array $options
* @throws Zend_Barcode_Object_Exception
* @throws Zend_Validate_Exception
*/
protected function _validateText($value, $options = array())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public function validateText($value)
/**
* Get barcode checksum
*
* @param string $text
* @param string $text
* @throws Zend_Barcode_Object_Exception
* @return int
*/
public function getChecksum($text)
Expand All @@ -85,7 +86,7 @@ public function getChecksum($text)
$checksum = 0;

for ($i = strlen($text); $i > 0; $i --) {
$checksum += intval($text{$i - 1}) * (($i % 2) ? 4 : 9);
$checksum += (int)$text[$i - 1] * (($i % 2) ? 4 : 9);
}

$checksum = (10 - ($checksum % 10)) % 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,9 @@ public function getFactor()
public function setForeColor($value)
{
if (preg_match('`\#[0-9A-F]{6}`', $value)) {
$this->_foreColor = hexdec($value);
$this->_foreColor = hexdec(ltrim($value, '#'));
} elseif (is_numeric($value) && $value >= 0 && $value <= 16777125) {
$this->_foreColor = intval($value);
$this->_foreColor = (int)$value;
} else {
// require_once 'Zend/Barcode/Object/Exception.php';
throw new Zend_Barcode_Object_Exception(
Expand Down Expand Up @@ -493,9 +493,9 @@ public function getForeColor()
public function setBackgroundColor($value)
{
if (preg_match('`\#[0-9A-F]{6}`', $value)) {
$this->_backgroundColor = hexdec($value);
$this->_backgroundColor = hexdec(ltrim($value, '#'));
} elseif (is_numeric($value) && $value >= 0 && $value <= 16777125) {
$this->_backgroundColor = intval($value);
$this->_backgroundColor = (int)$value;
} else {
// require_once 'Zend/Barcode/Object/Exception.php';
throw new Zend_Barcode_Object_Exception(
Expand Down Expand Up @@ -1322,7 +1322,7 @@ protected function _drawText()
for ($i = 0; $i < $textLength; $i ++) {
$leftPosition = $this->getQuietZone() + $space * ($i + 0.5);
$this->_addText(
$text{$i},
$text[$i],
$this->_fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
Expand Down
4 changes: 2 additions & 2 deletions packages/zend-barcode/library/Zend/Barcode/Object/Upca.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function _drawText()
$fontSize *= 0.8;
}
$this->_addText(
$text{$i},
$text[$i],
$fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
Expand All @@ -165,7 +165,7 @@ protected function _drawText()
default:
$factor = 0;
}
$leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
$leftPosition += $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
}
}
}
Expand Down
Loading