Skip to content

Fixes for PHP 8.1 compatibility #40

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
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion library/Zend/Db/Adapter/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@ public function quote($value, $type = null)
public function quoteInto($text, $value, $type = null, $count = null)
{
if ($count === null) {
return str_replace('?', $this->quote($value, $type), $text);
$quote = $this->quote($value, $type) ?? '""';
return str_replace('?', $quote, $text);
} else {
return implode($this->quote($value, $type), explode('?', $text, $count + 1));
}
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Db/Adapter/Pdo/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ protected function _quote($value)
return $value;
}
$this->_connect();
return $this->_connection->quote($value);
return $this->_connection->quote($value ?? '');
}

/**
Expand Down
1 change: 1 addition & 0 deletions library/Zend/Db/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ protected function _join($type, $name, $cond, $cols, $schema = null)
$tableName = $name;
$correlationName = $this->_uniqueCorrelation($tableName);
}
$tableName = $tableName ?? '';

// Schema from table name overrides schema argument
if (!is_object($tableName) && false !== strpos($tableName, '.')) {
Expand Down
3 changes: 2 additions & 1 deletion library/Zend/Db/Statement/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function _execute(array $params = null)
* @return mixed Array, object, or scalar depending on fetch mode.
* @throws Zend_Db_Statement_Exception
*/
public function fetch($style = null, $cursor = null, $offset = null)
public function fetch($style = null, $cursor = PDO::FETCH_ORI_NEXT, $offset = 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move these operations to the method code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @fascinosum , done

{
if ($style === null) {
$style = $this->_fetchMode;
Expand All @@ -263,6 +263,7 @@ public function fetch($style = null, $cursor = null, $offset = null)
*
* @return IteratorIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new IteratorIterator($this->_stmt);
Expand Down
9 changes: 6 additions & 3 deletions library/Zend/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,10 @@ public function isRedirect()
public function getBody()
{
$body = '';
$transferEncoding = $this->getHeader('transfer-encoding');

// Decode the body if it was transfer-encoded
switch (strtolower($this->getHeader('transfer-encoding'))) {
switch ($transferEncoding ? strtolower($transferEncoding) : '') {

// Handle chunked body
case 'chunked':
Expand All @@ -274,8 +275,10 @@ public function getBody()
break;
}

$contentEncoding = $this->getHeader('content-encoding');

// Decode any content-encoding (gzip or deflate) if needed
switch (strtolower($this->getHeader('content-encoding'))) {
switch ($contentEncoding ? strtolower($contentEncoding) : '') {

// Handle gzip encoding
case 'gzip':
Expand Down Expand Up @@ -603,7 +606,7 @@ public static function decodeChunkedBody($body)
// If mbstring overloads substr and strlen functions, we have to
// override it's internal encoding
if (function_exists('mb_internal_encoding') &&
((int) ini_get('mbstring.func_overload')) & 2) {
((int) ini_get('mbstring.func_overload')) & 2) {

$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Locale/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ public static function getContent($locale, $path, $value = false)
if (is_array($value)) {
$val = implode('_' , $value);
}
$val = urlencode($val);
$val = $val ? urlencode($val) : '';
$id = self::_filterCacheId('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val);
if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) {
return unserialize($result);
Expand Down
4 changes: 1 addition & 3 deletions library/Zend/Oauth/Http/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ public function generateTimestamp()
*/
public static function urlEncode($value)
{
$encoded = rawurlencode($value);
$encoded = str_replace('%7E', '~', $encoded);
return $encoded;
return $value ? str_replace('%7E', '~', rawurlencode($value)) : '';
}
}
88 changes: 78 additions & 10 deletions library/Zend/Pdf/RecursivelyIteratableObjectsContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,85 @@
*/
class Zend_Pdf_RecursivelyIteratableObjectsContainer implements RecursiveIterator, Countable
{
protected $_objects = array();
protected $_objects = [];

public function __construct(array $objects) { $this->_objects = $objects; }
/**
* @param array $objects
*/
public function __construct(array $objects)
{
$this->_objects = $objects;
}

public function current() { return current($this->_objects); }
public function key() { return key($this->_objects); }
public function next() { return next($this->_objects); }
public function rewind() { return reset($this->_objects); }
public function valid() { return current($this->_objects) !== false; }
public function getChildren() { return current($this->_objects); }
public function hasChildren() { return count($this->_objects) > 0; }
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function current()
{
return current($this->_objects);
}

public function count() { return count($this->_objects); }
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function key()
{
return key($this->_objects);
}

/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function next()
{
return next($this->_objects);
}

/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function rewind()
{
return reset($this->_objects);
}

/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function valid()
{
return current($this->_objects) !== false;
}

/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function getChildren()
{
return current($this->_objects);
}

/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function hasChildren()
{
return count($this->_objects) > 0;
}

/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->_objects);
}
}
2 changes: 1 addition & 1 deletion library/Zend/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ public function __construct($array = array(), $flags = parent::ARRAY_AS_PROPS)
*
* Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960).
*/
#[\ReturnTypeWillChange]
public function offsetExists($index)
{
return array_key_exists($index, $this);
}

}