Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2021-11-16 02:02:33 +0300
committerGitHub <noreply@github.com>2021-11-16 02:02:33 +0300
commitc4431ba4a12672d8bbb83c4063ff54df39f80b81 (patch)
treec23e1aa8bf5d2f3a841d6d99067ec980e43c3fa6 /libs
parentbd3e66993262f795a194386979cb56fe41ff6497 (diff)
Couple of fixes in QuickForm2 for PHP8.1 compatibility (#18309)
* couple of fixes in QuickForm2 for PHP8.1 compatibility * fix class order
Diffstat (limited to 'libs')
-rw-r--r--libs/HTML/QuickForm2/Container.php61
-rw-r--r--libs/HTML/QuickForm2/Controller.php2
-rw-r--r--libs/HTML/QuickForm2/Element/InputFile.php2
-rw-r--r--libs/HTML/QuickForm2/Element/Select.php55
-rw-r--r--libs/HTML/QuickForm2/Node.php4
5 files changed, 62 insertions, 62 deletions
diff --git a/libs/HTML/QuickForm2/Container.php b/libs/HTML/QuickForm2/Container.php
index 444f740b89..979b9b7e28 100644
--- a/libs/HTML/QuickForm2/Container.php
+++ b/libs/HTML/QuickForm2/Container.php
@@ -48,6 +48,34 @@
*/
// require_once 'HTML/QuickForm2/Node.php';
+
+/**
+ * Implements a recursive iterator for the container elements
+ *
+ * @category HTML
+ * @package HTML_QuickForm2
+ * @author Alexey Borzov <avb@php.net>
+ * @author Bertrand Mansion <golgote@mamasam.com>
+ * @version Release: @package_version@
+ */
+class HTML_QuickForm2_ContainerIterator extends RecursiveArrayIterator implements RecursiveIterator
+{
+ public function __construct(HTML_QuickForm2_Container $container)
+ {
+ parent::__construct($container->getElements());
+ }
+
+ public function hasChildren()
+ {
+ return $this->current() instanceof HTML_QuickForm2_Container;
+ }
+
+ public function getChildren()
+ {
+ return new HTML_QuickForm2_ContainerIterator($this->current());
+ }
+}
+
/**
* Abstract base class for simple QuickForm2 containers
*
@@ -323,7 +351,7 @@ abstract class HTML_QuickForm2_Container extends HTML_QuickForm2_Node
*
* @return HTML_QuickForm2_ContainerIterator
*/
- public function getIterator()
+ public function getIterator(): HTML_QuickForm2_ContainerIterator
{
return new HTML_QuickForm2_ContainerIterator($this);
}
@@ -334,7 +362,7 @@ abstract class HTML_QuickForm2_Container extends HTML_QuickForm2_Node
* @param int mode passed to RecursiveIteratorIterator
* @return RecursiveIteratorIterator
*/
- public function getRecursiveIterator($mode = RecursiveIteratorIterator::SELF_FIRST)
+ public function getRecursiveIterator($mode = RecursiveIteratorIterator::SELF_FIRST): RecursiveIteratorIterator
{
return new RecursiveIteratorIterator(
new HTML_QuickForm2_ContainerIterator($this), $mode
@@ -346,7 +374,7 @@ abstract class HTML_QuickForm2_Container extends HTML_QuickForm2_Node
*
* @return int
*/
- public function count()
+ public function count(): int
{
return count($this->elements);
}
@@ -457,31 +485,4 @@ abstract class HTML_QuickForm2_Container extends HTML_QuickForm2_Node
}
}
-/**
- * Implements a recursive iterator for the container elements
- *
- * @category HTML
- * @package HTML_QuickForm2
- * @author Alexey Borzov <avb@php.net>
- * @author Bertrand Mansion <golgote@mamasam.com>
- * @version Release: @package_version@
- */
-class HTML_QuickForm2_ContainerIterator extends RecursiveArrayIterator implements RecursiveIterator
-{
- public function __construct(HTML_QuickForm2_Container $container)
- {
- parent::__construct($container->getElements());
- }
-
- public function hasChildren()
- {
- return $this->current() instanceof HTML_QuickForm2_Container;
- }
-
- public function getChildren()
- {
- return new HTML_QuickForm2_ContainerIterator($this->current());
- }
-}
-
?>
diff --git a/libs/HTML/QuickForm2/Controller.php b/libs/HTML/QuickForm2/Controller.php
index 440d1005a2..c3695cdbb6 100644
--- a/libs/HTML/QuickForm2/Controller.php
+++ b/libs/HTML/QuickForm2/Controller.php
@@ -500,7 +500,7 @@ class HTML_QuickForm2_Controller implements IteratorAggregate
*
* @return ArrayIterator
*/
- public function getIterator()
+ public function getIterator(): ArrayIterator
{
return new ArrayIterator($this->pages);
}
diff --git a/libs/HTML/QuickForm2/Element/InputFile.php b/libs/HTML/QuickForm2/Element/InputFile.php
index 784e6d3379..7db29c3bef 100644
--- a/libs/HTML/QuickForm2/Element/InputFile.php
+++ b/libs/HTML/QuickForm2/Element/InputFile.php
@@ -224,7 +224,7 @@ class HTML_QuickForm2_Element_InputFile extends HTML_QuickForm2_Element_Input
*/
protected function validate()
{
- if (strlen($this->error)) {
+ if (strlen($this->error ?? '')) {
return false;
}
if (isset($this->value['error']) &&
diff --git a/libs/HTML/QuickForm2/Element/Select.php b/libs/HTML/QuickForm2/Element/Select.php
index 2c852d6af7..d336b66c6d 100644
--- a/libs/HTML/QuickForm2/Element/Select.php
+++ b/libs/HTML/QuickForm2/Element/Select.php
@@ -48,6 +48,30 @@
*/
// require_once 'HTML/QuickForm2/Element.php';
+/**
+ * Implements a recursive iterator for options arrays
+ *
+ * @category HTML
+ * @package HTML_QuickForm2
+ * @author Alexey Borzov <avb@php.net>
+ * @author Bertrand Mansion <golgote@mamasam.com>
+ * @version Release: @package_version@
+ */
+class HTML_QuickForm2_Element_Select_OptionIterator extends RecursiveArrayIterator
+ implements RecursiveIterator
+{
+ public function hasChildren()
+ {
+ return $this->current() instanceof HTML_QuickForm2_Element_Select_OptionContainer;
+ }
+
+ public function getChildren()
+ {
+ return new HTML_QuickForm2_Element_Select_OptionIterator(
+ $this->current()->getOptions()
+ );
+ }
+}
/**
* Collection of <option>s and <optgroup>s
@@ -187,7 +211,7 @@ class HTML_QuickForm2_Element_Select_OptionContainer extends HTML_Common2
*
* @return HTML_QuickForm2_Element_Select_OptionIterator
*/
- public function getIterator()
+ public function getIterator(): HTML_QuickForm2_Element_Select_OptionIterator
{
return new HTML_QuickForm2_Element_Select_OptionIterator($this->options);
}
@@ -197,7 +221,7 @@ class HTML_QuickForm2_Element_Select_OptionContainer extends HTML_Common2
*
* @return RecursiveIteratorIterator
*/
- public function getRecursiveIterator()
+ public function getRecursiveIterator(): RecursiveIteratorIterator
{
return new RecursiveIteratorIterator(
new HTML_QuickForm2_Element_Select_OptionIterator($this->options),
@@ -210,7 +234,7 @@ class HTML_QuickForm2_Element_Select_OptionContainer extends HTML_Common2
*
* @return int
*/
- public function count()
+ public function count(): int
{
return count($this->options);
}
@@ -257,31 +281,6 @@ class HTML_QuickForm2_Element_Select_Optgroup
}
}
-/**
- * Implements a recursive iterator for options arrays
- *
- * @category HTML
- * @package HTML_QuickForm2
- * @author Alexey Borzov <avb@php.net>
- * @author Bertrand Mansion <golgote@mamasam.com>
- * @version Release: @package_version@
- */
-class HTML_QuickForm2_Element_Select_OptionIterator extends RecursiveArrayIterator
- implements RecursiveIterator
-{
- public function hasChildren()
- {
- return $this->current() instanceof HTML_QuickForm2_Element_Select_OptionContainer;
- }
-
- public function getChildren()
- {
- return new HTML_QuickForm2_Element_Select_OptionIterator(
- $this->current()->getOptions()
- );
- }
-}
-
/**
* Class representing a <select> element
diff --git a/libs/HTML/QuickForm2/Node.php b/libs/HTML/QuickForm2/Node.php
index e83e4d57ee..e0ce83ed2f 100644
--- a/libs/HTML/QuickForm2/Node.php
+++ b/libs/HTML/QuickForm2/Node.php
@@ -585,14 +585,14 @@ abstract class HTML_QuickForm2_Node extends HTML_Common2
protected function validate()
{
foreach ($this->rules as $rule) {
- if (strlen($this->error)) {
+ if (strlen($this->error ?? '')) {
break;
}
if ($rule[1] & HTML_QuickForm2_Rule::RUNAT_SERVER) {
$rule[0]->validate();
}
}
- return !strlen($this->error);
+ return !strlen($this->error ?? '');
}
/**