Merge pull request #8094 from dhensby/pulls/3/php72-each-removal

FIX Remove use of deprecated each method from thirdparty
This commit is contained in:
Loz Calver 2018-06-04 16:56:03 +01:00 committed by GitHub
commit e987708470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 45 additions and 31 deletions

View File

@ -278,15 +278,17 @@ class _DiffEngine
if (empty($ymatches[$line]))
continue;
$matches = $ymatches[$line];
reset($matches);
while (list ($junk, $y) = each($matches))
$y = reset($matches);
do {
if (empty($this->in_seq[$y])) {
$k = $this->_lcs_pos($y);
USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k-1];
break;
}
while (list ($junk, $y) = each($matches)) {
$k = $this->_lcs_pos($y);
USE_ASSERTS && assert($k > 0);
$ymids[$k] = $ymids[$k - 1];
break;
}
} while (false !== ($y = next($matches)));
while (false !== ($y = next($matches))) {
if ($y > $this->seq[$k-1]) {
USE_ASSERTS && assert($y < $this->seq[$k]);
// Optimization: this is a common case:
@ -797,18 +799,19 @@ class Diff
$content = str_replace(array("&nbsp;","<", ">"),array(" "," <", "> "),$content);
$candidateChunks = preg_split("/[\t\r\n ]+/", $content);
while(list($i,$item) = each($candidateChunks)) {
$item = reset($candidateChunks);
do {
if(isset($item[0]) && $item[0] == "<") {
$newChunk = $item;
while($item[strlen($item)-1] != ">") {
list($i,$item) = each($candidateChunks);
$item = next($candidateChunks);
$newChunk .= ' ' . $item;
}
$chunks[] = $newChunk;
} else {
$chunks[] = $item;
}
}
} while (false !== ($item = next($candidateChunks)));
return $chunks;
}

View File

@ -161,7 +161,7 @@ class Profiler {
echo"============================================================================\n";
print( "Calls Time Routine\n");
echo"-----------------------------------------------------------------------------\n";
while (list ($key, $val) = each ($this->description)) {
foreach ($this->description as $key => $val) {
$t = $this->elapsedTime($key);
$total = $this->running[$key];
$count = $this->count[$key];

View File

@ -337,26 +337,34 @@ class GridField extends FormField {
'before' => true,
'after' => true,
);
$fragmentDeferred = array();
reset($content);
// TODO: Break the below into separate reducer methods
while(list($contentKey, $contentValue) = each($content)) {
if(preg_match_all('/\$DefineFragment\(([a-z0-9\-_]+)\)/i', $contentValue, $matches)) {
foreach($matches[1] as $match) {
// Continue looping if any placeholders exist
while (array_filter($content, function ($value) {
return preg_match('/\$DefineFragment\(([a-z0-9\-_]+)\)/i', $value);
})) {
foreach ($content as $contentKey => $contentValue) {
// Skip if this specific content has no placeholders
if (!preg_match_all('/\$DefineFragment\(([a-z0-9\-_]+)\)/i', $contentValue, $matches)) {
continue;
}
foreach ($matches[1] as $match) {
$fragmentName = strtolower($match);
$fragmentDefined[$fragmentName] = true;
$fragment = '';
if(isset($content[$fragmentName])) {
if (isset($content[$fragmentName])) {
$fragment = $content[$fragmentName];
}
// If the fragment still has a fragment definition in it, when we should defer
// this item until later.
if(preg_match('/\$DefineFragment\(([a-z0-9\-_]+)\)/i', $fragment, $matches)) {
if(isset($fragmentDeferred[$contentKey]) && $fragmentDeferred[$contentKey] > 5) {
if (preg_match('/\$DefineFragment\(([a-z0-9\-_]+)\)/i', $fragment, $matches)) {
if (isset($fragmentDeferred[$contentKey]) && $fragmentDeferred[$contentKey] > 5) {
throw new LogicException(sprintf(
'GridField HTML fragment "%s" and "%s" appear to have a circular dependency.',
$fragmentName,
@ -368,7 +376,7 @@ class GridField extends FormField {
$content[$contentKey] = $contentValue;
if(!isset($fragmentDeferred[$contentKey])) {
if (!isset($fragmentDeferred[$contentKey])) {
$fragmentDeferred[$contentKey] = 0;
}
@ -386,6 +394,7 @@ class GridField extends FormField {
}
}
// Check for any undefined fragments, and if so throw an exception.
// While we're at it, trim whitespace off the elements.
@ -587,7 +596,7 @@ class GridField extends FormField {
} else {
$classes[] = 'odd';
}
$this->extend('updateNewRowClasses', $classes, $total, $index, $record);
return $classes;

View File

@ -247,8 +247,10 @@ class Hierarchy extends DataExtension {
$this->markedNodes = array($this->owner->ID => $this->owner);
$this->owner->markUnexpanded();
$node = reset($this->markedNodes);
// foreach can't handle an ever-growing $nodes list
while(list($id, $node) = each($this->markedNodes)) {
do {
// first determine the number of children, if it's too high the tree view can't be used
// so will will not even bother to display the subtree
// this covers two cases:
@ -267,7 +269,7 @@ class Hierarchy extends DataExtension {
if($children) foreach($children as $child) $child->markClosed();
break;
}
}
} while (false !== ($node = next($this->markedNodes)));
return sizeof($this->markedNodes);
}

View File

@ -63,7 +63,7 @@ class Zend_Cache_Backend
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
}
@ -78,7 +78,7 @@ class Zend_Cache_Backend
public function setDirectives($directives)
{
if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array');
while (list($name, $value) = each($directives)) {
foreach ($directives as $name => $value) {
if (!is_string($name)) {
Zend_Cache::throwException("Incorrect option name : $name");
}

View File

@ -143,7 +143,7 @@ class Zend_Cache_Core
Zend_Cache::throwException("Options passed were not an array"
. " or Zend_Config instance.");
}
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
$this->_loggerSanity();
@ -158,7 +158,7 @@ class Zend_Cache_Core
public function setConfig(Zend_Config $config)
{
$options = $config->toArray();
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
return $this;

View File

@ -107,7 +107,7 @@ class Zend_Cache_Frontend_Class extends Zend_Cache_Core
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
if ($this->_specificOptions['cached_entity'] === null) {

View File

@ -88,7 +88,7 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
if (!isset($this->_specificOptions['master_files'])) {

View File

@ -63,7 +63,7 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
$this->setOption('automatic_serialization', true);

View File

@ -129,7 +129,7 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$name = strtolower($name);
switch ($name) {
case 'regexps':