the fact of real shit

Changing ZF2 Core 2.4.13 Zend\View\Helper\HeadLink::createDataStylesheet

class: Zend\View\Helper\HeadLink
function: createDataStylesheet
php version: 7.3

public function createDataStylesheet(array $args)
{
$rel = ‘stylesheet’;
$type = ‘text/css’;
$media = ‘screen’;
$conditionalStylesheet = false;
$href = array_shift($args);
if ($this->isDuplicateStylesheet($href)) { return false; } if (0 < count($args)) { $media = array_shift($args); if (is_array($media)) { $media = implode(',', $media); } else { $media = (string) $media; } } if (0 < count($args)) { $conditionalStylesheet = array_shift($args); if (!empty($conditionalStylesheet) && is_string($conditionalStylesheet)) { $conditionalStylesheet = (string) $conditionalStylesheet; } else { $conditionalStylesheet = null; } } $attributes = compact('rel', 'type', 'href', 'media', 'conditionalStylesheet'); if (0 < count($args) && is_array($args[0])) { $extras = array_shift($args); $attributes['extras'] = (array) $extras; } return $this->createData($attributes); }

new/modified/final/current code

public function createDataStylesheet(array $args)
{
$rel = ‘stylesheet’;
$type = ‘text/css’;
$media = ‘screen’;
$conditionalStylesheet = false;
$href = array_shift($args);
if ($this->isDuplicateStylesheet($href)) { return false; } if (0 < count($args)) { $media = array_shift($args); if (is_array($media)) { $media = implode(',', $media); } else { $media = (string) $media; } } if (0 < count($args)) { $conditionalStylesheet = array_shift($args); if (!empty($conditionalStylesheet) && is_string($conditionalStylesheet)) { $conditionalStylesheet = (string) $conditionalStylesheet; } else { $conditionalStylesheet = null; } } if (0 < count($args) && is_array($args[0])) { $extras = array_shift($args); $extras = (array) $extras; } $attributes = compact('rel', 'type', 'href', 'media', 'conditionalStylesheet', 'extras'); return $this->createData($attributes); }

previous/original/old code
Posted in php, zf2Tagged , , , ,

changing zf2 core 2.4.13 Zend/Stdlib/ArrayObject.php

class : Zend\Stdlib\ArrayObject
function: unserialize($data)
php version: 7.3

previous (original) code

/**
* Unserialize an ArrayObject
*
* @param string $data
* @return void
*/
public function unserialize($data)
{
$ar = unserialize($data);
$this->protectedProperties = array_keys(get_object_vars($this));

$this->setFlags($ar[‘flag’]);
$this->exchangeArray($ar[‘storage’]);
$this->setIteratorClass($ar[‘iteratorClass’]);

foreach ($ar as $k => $v) {
switch ($k) {
case ‘flag’:
$this->setFlags($v);
break;
case ‘storage’:
$this->exchangeArray($v);
break;
case ‘iteratorClass’:
$this->setIteratorClass($v);
break;
case ‘protectedProperties’:
continue;
default:
$this->__set($k, $v);
}
}
}

new code

public function unserialize($data)
{
$ar = unserialize($data);
$this->protectedProperties = array_keys(get_object_vars($this));

$this->setFlags($ar[‘flag’]);
$this->exchangeArray($ar[‘storage’]);
$this->setIteratorClass($ar[‘iteratorClass’]);

$need2continue=false;
foreach ($ar as $k => $v) {
$need2continue=false;
switch ($k) {
case ‘flag’:
$this->setFlags($v);
break;
case ‘storage’:
$this->exchangeArray($v);
break;
case ‘iteratorClass’:
$this->setIteratorClass($v);
break;
case ‘protectedProperties’:
/**
* in php 7.3 it shows
* Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in /…location of zf2 ………../Zend/Stdlib/ArrayObject.php on line 426
*/
#continue;
$need2continue=true;
break;
default:
$this->__set($k, $v);
}
if(true==$need2continue) continue;
}
}

 

Posted in php, zf2Tagged , , , ,