Merge pull request #4013 from Icinga/feature/support-for-php-7.4-4009

Support for PHP 7.4
This commit is contained in:
Johannes Meyer 2019-12-04 11:35:04 +01:00 committed by GitHub
commit 3900929a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 94 additions and 100 deletions

View File

@ -1,13 +1,13 @@
language: php
dist: trusty
dist: xenial
sudo: false
php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- nightly
env:
@ -15,18 +15,26 @@ env:
matrix:
include:
- env: CHECK=phpcs
php: '7.4'
- env: CHECK=phpcs
php: '7.3'
- env: CHECK=phpcs
php: '7.0'
php: '7.2'
- env: CHECK=phpcs
php: '7.1'
- env: CHECK=phpcs
php: '5.6'
- env: CHECK=syntax
php: 'nightly'
- env: CHECK=syntax
php: '7.4'
- env: CHECK=syntax
php: '7.3'
- env: CHECK=syntax
php: '7.0'
php: '7.2'
- env: CHECK=syntax
php: '7.1'
- env: CHECK=syntax
php: '5.6'
allow_failures:

View File

@ -320,7 +320,7 @@ class ResourceConfigForm extends ConfigForm
if ($this->getElement('resource_validation')->isChecked() && parent::isValid($formData)) {
$inspection = static::inspectResource($this);
if ($inspection !== null) {
$join = function ($e) use (& $join) {
$join = function ($e) use (&$join) {
return is_string($e) ? $e : join("\n", array_map($join, $e));
};
$this->addElement(

View File

@ -69,7 +69,7 @@ class UserBackendConfigForm extends ConfigForm
$externalBackends = $this->config->toArray();
array_walk(
$externalBackends,
function (& $authBackendCfg) {
function (&$authBackendCfg) {
if (! isset($authBackendCfg['backend']) || $authBackendCfg['backend'] !== 'external') {
$authBackendCfg = null;
}
@ -397,7 +397,7 @@ class UserBackendConfigForm extends ConfigForm
if ($this->getElement('backend_validation')->isChecked() && parent::isValid($formData)) {
$inspection = static::inspectUserBackend($this);
if ($inspection !== null) {
$join = function ($e) use (& $join) {
$join = function ($e) use (&$join) {
return is_string($e) ? $e : join("\n", array_map($join, $e));
};
$this->addElement(

View File

@ -229,7 +229,7 @@ class UserGroupBackendForm extends ConfigForm
if (isset($formData['backend_validation']) && parent::isValid($formData)) {
$inspection = static::inspectUserBackend($this);
if ($inspection !== null) {
$join = function ($e) use (& $join) {
$join = function ($e) use (&$join) {
return is_string($e) ? $e : join("\n", array_map($join, $e));
};
$this->addElement(

View File

@ -350,7 +350,7 @@ class RoleForm extends RepositoryForm
return $success ? $this->translate('Role removed') : $this->translate('Role removal failed');
}
protected function sortPermissions(& $permissions)
protected function sortPermissions(&$permissions)
{
return uasort($permissions, function ($a, $b) {
if (isset($a['isUsagePerm'])) {

View File

@ -170,7 +170,7 @@ class Web extends EmbeddedWeb
return $this->viewRenderer;
}
private function hasAccessToSharedNavigationItem(& $config, Config $navConfig)
private function hasAccessToSharedNavigationItem(&$config, Config $navConfig)
{
// TODO: Provide a more sophisticated solution

View File

@ -297,7 +297,9 @@ class Donut
'r' => sprintf('%F', $this->radius),
'fill' => 'transparent',
'stroke-width' => $this->getThickness(),
'stroke-dasharray' => sprintf('%F', $slice[0]) . ' ' . sprintf('%F', (99.9 - $slice[0])), // 99.9 prevents gaps (slight overlap)
'stroke-dasharray' => sprintf('%F', $slice[0])
. ' '
. sprintf('%F', (99.9 - $slice[0])), // 99.9 prevents gaps (slight overlap)
'stroke-dashoffset' => sprintf('%F', $offset)
)
);

View File

@ -889,13 +889,17 @@ class LdapConnection implements Selectable, Inspectable
}
}
$legacyControlHandling = version_compare(PHP_VERSION, '7.3.0') < 0;
$count = 0;
$cookie = '';
$entries = array();
do {
// Do not request the pagination control as a critical extension, as we want the
// server to return results even if the paged search request cannot be satisfied
ldap_control_paged_result($ds, $pageSize, false, $cookie);
if ($legacyControlHandling) {
// Do not request the pagination control as a critical extension, as we want the
// server to return results even if the paged search request cannot be satisfied
ldap_control_paged_result($ds, $pageSize, false, $cookie);
}
if ($serverSorting && $query->hasOrder()) {
ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array(
@ -910,7 +914,10 @@ class LdapConnection implements Selectable, Inspectable
$query,
array_values($fields),
0,
($serverSorting || ! $query->hasOrder()) && $limit ? $offset + $limit : 0
($serverSorting || ! $query->hasOrder()) && $limit ? $offset + $limit : 0,
0,
LDAP_DEREF_NEVER,
$legacyControlHandling ? null : $pageSize
);
if ($results === false) {
if (ldap_errno($ds) === self::LDAP_NO_SUCH_OBJECT) {
@ -976,7 +983,7 @@ class LdapConnection implements Selectable, Inspectable
&& ($entry = ldap_next_entry($ds, $entry))
);
if (false === @ldap_control_paged_result_response($ds, $results, $cookie)) {
if ($legacyControlHandling && false === @ldap_control_paged_result_response($ds, $results, $cookie)) {
// If the page size is greater than or equal to the sizeLimit value, the server should ignore the
// control as the request can be satisfied in a single page: https://www.ietf.org/rfc/rfc2696.txt
// This applies no matter whether paged search requests are permitted or not. You're done once you
@ -993,7 +1000,7 @@ class LdapConnection implements Selectable, Inspectable
ldap_free_result($results);
} while ($cookie && (! $serverSorting || $limit === 0 || count($entries) < $limit));
if ($cookie) {
if ($legacyControlHandling && $cookie) {
// A sequence of paged search requests is abandoned by the client sending a search request containing a
// pagedResultsControl with the size set to zero (0) and the cookie set to the last cookie returned by
// the server: https://www.ietf.org/rfc/rfc2696.txt
@ -1219,6 +1226,7 @@ class LdapConnection implements Selectable, Inspectable
* @param int $sizelimit Enables you to limit the count of entries fetched
* @param int $timelimit Sets the number of seconds how long is spend on the search
* @param int $deref
* @param int $pageSize The page size to request (Only supported with PHP v7.3+)
*
* @return resource|bool A search result identifier or false on error
*
@ -1230,7 +1238,8 @@ class LdapConnection implements Selectable, Inspectable
$attrsonly = 0,
$sizelimit = 0,
$timelimit = 0,
$deref = LDAP_DEREF_NEVER
$deref = LDAP_DEREF_NEVER,
$pageSize = null
) {
$queryString = (string) $query;
$baseDn = $query->getBase() ?: $this->getDn();
@ -1285,6 +1294,20 @@ class LdapConnection implements Selectable, Inspectable
throw new LogicException('LDAP scope %s not supported by ldapSearch', $scope);
}
$serverctrls = [];
if ($pageSize !== null) {
$serverctrls[] = [
'oid' => LDAP_CONTROL_PAGEDRESULTS,
// Do not request the pagination control as a critical extension, as we want the
// server to return results even if the paged search request cannot be satisfied
'iscritical' => false,
'value' => [
'size' => $pageSize,
'cookie' => ''
]
];
}
return @$function(
$this->getConnection(),
$baseDn,
@ -1293,7 +1316,8 @@ class LdapConnection implements Selectable, Inspectable
$attrsonly,
$sizelimit,
$timelimit,
$deref
$deref,
$serverctrls
);
}

View File

@ -405,7 +405,7 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
*
* @throws ProgrammingError In case no valid section name is available
*/
protected function extractSectionName(& $config, $keyColumn)
protected function extractSectionName(&$config, $keyColumn)
{
if (! is_array($config) && !$config instanceof ConfigObject) {
throw new ProgrammingError('$config is neither an array nor a ConfigObject');

View File

@ -68,7 +68,7 @@ class Format
return sprintf('%0.2f d', $value / 86400);
}
protected static function formatForUnits($value, & $units, $base)
protected static function formatForUnits($value, &$units, $base)
{
$sign = '';
if ($value < 0) {

View File

@ -1120,7 +1120,7 @@ class Form extends Zend_Form
* @param Zend_Form $form
* @param array $defaults
*/
protected function preserveDefaults(Zend_Form $form, array & $defaults)
protected function preserveDefaults(Zend_Form $form, array &$defaults)
{
foreach ($form->getElements() as $name => $element) {
if ((array_key_exists($name, $defaults)

View File

@ -95,7 +95,7 @@ class FormHints extends Zend_Form_Decorator_Abstract
*
* @return array
*/
protected function recurseForm(Form $form, & $entirelyRequired = null, $elementsPassed = false)
protected function recurseForm(Form $form, &$entirelyRequired = null, $elementsPassed = false)
{
$requiredLabels = array();
if ($form->getRequiredCue() !== null) {

View File

@ -59,13 +59,6 @@ class View extends Zend_View_Abstract
*/
const CHARSET = 'UTF-8';
/**
* Flag to register stream wrapper
*
* @var bool
*/
private $useViewStream = false;
/**
* Registered helper functions
*/
@ -86,13 +79,6 @@ class View extends Zend_View_Abstract
*/
public function __construct($config = array())
{
$this->useViewStream = (bool) ini_get('short_open_tag') ? false : true;
if ($this->useViewStream) {
if (!in_array('zend.view', stream_get_wrappers())) {
stream_wrapper_register('zend.view', '\Icinga\Web\ViewStream');
}
}
$config['helperPath']['Icinga\\Web\\View\\Helper\\'] = Icinga::app()->getLibraryDir('Icinga/Web/View/Helper');
parent::__construct($config);
@ -258,11 +244,8 @@ class View extends Zend_View_Abstract
// Exporting global variables to view scripts:
$$k = $v;
}
if ($this->useViewStream) {
include 'zend.view://' . func_get_arg(0);
} else {
include func_get_arg(0);
}
include func_get_arg(0);
}
/**

View File

@ -1,13 +0,0 @@
<?php
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
namespace Icinga\Web;
use Zend_View_Stream;
/**
* Is used in Icinga\Web\View to imitate PHP's short_open_tag
*/
class ViewStream extends Zend_View_Stream
{
}

View File

@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
protected function _compileRegex()
{
$raw = str_replace(' ', '', $this->dtd_regex);
if ($raw{0} != '(') {
if ($raw[0] != '(') {
$raw = "($raw)";
}
$el = '[#a-zA-Z0-9_.-]+';

View File

@ -159,7 +159,7 @@ class HTMLPurifier_Encoder
$len = strlen($str);
for ($i = 0; $i < $len; $i++) {
$in = ord($str{$i});
$in = ord($str[$i]);
$char .= $str[$i]; // append byte to char
if (0 == $mState) {
// When mState is zero we expect either a US-ASCII character

View File

@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
if (isset($attr['size'])) {
// normalize large numbers
if ($attr['size'] !== '') {
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') {
if ($attr['size'][0] == '+' || $attr['size'][0] == '-') {
$size = (int)$attr['size'];
if ($size < -2) {
$attr['size'] = '-2';

View File

@ -227,7 +227,7 @@ class Zend_Filter_Compress_Zip extends Zend_Filter_Compress_CompressAbstract
for ($i = 0; $i < $zip->numFiles; $i++) {
$statIndex = $zip->statIndex($i);
$currName = $statIndex['name'];
if (($currName{0} == '/') ||
if (($currName[0] == '/') ||
(substr($currName, 0, 2) == '..') ||
(substr($currName, 0, 4) == './..')
)

View File

@ -317,7 +317,7 @@ class Zend_Json_Decoder
$i = $this->_offset;
$start = $i;
switch ($str{$i}) {
switch ($str[$i]) {
case '{':
$this->_token = self::LBRACE;
break;
@ -344,14 +344,14 @@ class Zend_Json_Decoder
break;
}
$chr = $str{$i};
$chr = $str[$i];
if ($chr == '\\') {
$i++;
if ($i >= $str_length) {
break;
}
$chr = $str{$i};
$chr = $str[$i];
switch ($chr) {
case '"' :
$result .= '"';
@ -423,7 +423,7 @@ class Zend_Json_Decoder
return($this->_token);
}
$chr = $str{$i};
$chr = $str[$i];
if ($chr == '-' || $chr == '.' || ($chr >= '0' && $chr <= '9')) {
if (preg_match('/-?([0-9])*(\.[0-9]*)?((e|E)((-|\+)?)[0-9]+)?/s',
$str, $matches, PREG_OFFSET_CAPTURE, $start) && $matches[0][1] == $start) {
@ -483,7 +483,7 @@ class Zend_Json_Decoder
$i += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$i};
$utf8 .= $chrs[$i];
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
@ -541,7 +541,7 @@ class Zend_Json_Decoder
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
$bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
switch (true) {
case ((0x7F & $bytes) == $bytes):

View File

@ -556,17 +556,17 @@ class Zend_Json_Encoder
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
return chr(0x07 & (ord($utf8[0]) >> 2))
. chr((0xC0 & (ord($utf8[0]) << 6))
| (0x3F & ord($utf8[1])));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
return chr((0xF0 & (ord($utf8[0]) << 4))
| (0x0F & (ord($utf8[1]) >> 2)))
. chr((0xC0 & (ord($utf8[1]) << 6))
| (0x7F & ord($utf8[2])));
}
// ignoring UTF-32 for now, sorry

View File

@ -189,16 +189,4 @@ class Zend_Registry extends ArrayObject
{
parent::__construct($array, $flags);
}
/**
* @param string $index
* @returns mixed
*
* Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960).
*/
public function offsetExists($index)
{
return array_key_exists($index, $this);
}
}

View File

@ -165,7 +165,7 @@ class Zend_Validate_Isbn extends Zend_Validate_Abstract
$isbn10 = str_replace($this->_separator, '', $value);
$sum = 0;
for ($i = 0; $i < 9; $i++) {
$sum += (10 - $i) * $isbn10{$i};
$sum += (10 - $i) * $isbn10[$i];
}
// checksum
@ -183,9 +183,9 @@ class Zend_Validate_Isbn extends Zend_Validate_Abstract
$sum = 0;
for ($i = 0; $i < 12; $i++) {
if ($i % 2 == 0) {
$sum += $isbn13{$i};
$sum += $isbn13[$i];
} else {
$sum += 3 * $isbn13{$i};
$sum += 3 * $isbn13[$i];
}
}
// checksum

View File

@ -662,7 +662,7 @@ class lessc {
// check for a rest
$last = end($args);
if ($last[0] == "rest") {
if (is_array($last) && $last[0] == "rest") {
$rest = array_slice($orderedValues, count($args) - 1);
$this->set($last[1], $this->reduce(array("list", " ", $rest)));
}
@ -746,7 +746,7 @@ class lessc {
if ($suffix !== null &&
$subProp[0] == "assign" &&
is_string($subProp[1]) &&
$subProp[1]{0} != $this->vPrefix)
$subProp[1][0] != $this->vPrefix)
{
$subProp[2] = array(
'list', ' ',
@ -1857,7 +1857,7 @@ class lessc {
$this->pushEnv();
$parser = new lessc_parser($this, __METHOD__);
foreach ($args as $name => $strValue) {
if ($name{0} != '@') $name = '@'.$name;
if ($name[0] != '@') $name = '@'.$name;
$parser->count = 0;
$parser->buffer = (string)$strValue;
if (!$parser->propertyValue($value)) {
@ -2516,7 +2516,7 @@ class lessc_parser {
$hidden = true;
if (!isset($block->args)) {
foreach ($block->tags as $tag) {
if (!is_string($tag) || $tag{0} != $this->lessc->mPrefix) {
if (!is_string($tag) || $tag[0] != $this->lessc->mPrefix) {
$hidden = false;
break;
}
@ -2570,7 +2570,7 @@ class lessc_parser {
protected function fixTags($tags) {
// move @ tags out of variable namespace
foreach ($tags as &$tag) {
if ($tag{0} == $this->lessc->vPrefix)
if ($tag[0] == $this->lessc->vPrefix)
$tag[0] = $this->lessc->mPrefix;
}
return $tags;

View File

@ -120,7 +120,7 @@ class IdoResourcePage extends Form
$inspection = ResourceConfigForm::inspectResource($this);
if ($inspection !== null) {
if ($showLog) {
$join = function ($e) use (& $join) {
$join = function ($e) use (&$join) {
return is_string($e) ? $e : join("\n", array_map($join, $e));
};
$this->addElement(

View File

@ -94,7 +94,7 @@ class CliUtils
);
}
public function objectStateFlags($type, & $row)
public function objectStateFlags($type, &$row)
{
$extra = array();
if ($row->{$type . '_in_downtime'}) {

View File

@ -140,7 +140,10 @@ class MonitoringWizard extends Wizard implements SetupWizard
$setup->addStep(
new BackendStep(array(
'backendConfig' => $pageData['setup_monitoring_backend'],
'resourceConfig' => array_diff_key($pageData['setup_monitoring_ido'], array('skip_validation' => null)) //TODO: Prefer a new backend once implemented.
'resourceConfig' => array_diff_key(
$pageData['setup_monitoring_ido'], //TODO: Prefer a new backend once implemented.
array('skip_validation' => null)
)
))
);

View File

@ -188,7 +188,7 @@ class AuthBackendPage extends Form
$inspection = UserBackendConfigForm::inspectUserBackend($self);
if ($inspection !== null) {
$join = function ($e) use (& $join) {
$join = function ($e) use (&$join) {
return is_string($e) ? $e : join("\n", array_map($join, $e));
};
$this->addElement(

View File

@ -97,7 +97,7 @@ class LdapResourcePage extends Form
if (isset($formData['backend_validation']) && parent::isValid($formData)) {
$inspection = ResourceConfigForm::inspectResource($this);
if ($inspection !== null) {
$join = function ($e) use (& $join) {
$join = function ($e) use (&$join) {
return is_string($e) ? $e : join("\n", array_map($join, $e));
};
$this->addElement(

View File

@ -127,8 +127,7 @@ class ArrayToTextTableHelper
$this->printHeading();
$rc = count($this->rows);
for ($i = 0; $i < $rc;
$i++) {
for ($i = 0; $i < $rc; $i++) {
$this->printRow($i);
}

View File

@ -3,7 +3,7 @@
set -ex
ICINGAWEB_HOME=${ICINGAWEB_HOME:="$(dirname "$(readlink -f "$(dirname "$0")")")"}
PHPCS_VERSION=${PHPCS_VERSION:=3.3.2}
PHPCS_VERSION=${PHPCS_VERSION:=3.5.3}
MOCKERY_VERSION=${MOCKERY_VERSION:=0.9.9}
HAMCREST_VERSION=${HAMCREST_VERSION:=2.0.0}
PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7}