Skip to content

Commit c92cafc

Browse files
authored
Updated lib/Varien for PHP8.1 (#2802)
1 parent 66af7ed commit c92cafc

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

lib/Varien/Data/Form/Element/Collection.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct($container)
5858
*
5959
* @return ArrayIterator
6060
*/
61-
public function getIterator()
61+
public function getIterator(): \Traversable
6262
{
6363
return new ArrayIterator($this->_elements);
6464
}
@@ -69,7 +69,7 @@ public function getIterator()
6969
* @param mixed $key
7070
* @param mixed $value
7171
*/
72-
public function offsetSet($key, $value)
72+
public function offsetSet($key, $value): void
7373
{
7474
$this->_elements[$key] = $value;
7575
}
@@ -80,7 +80,7 @@ public function offsetSet($key, $value)
8080
* @param mixed $key
8181
* @return mixed
8282
*/
83-
public function offsetGet($key)
83+
public function offsetGet($key): mixed
8484
{
8585
return $this->_elements[$key];
8686
}
@@ -90,7 +90,7 @@ public function offsetGet($key)
9090
*
9191
* @param mixed $key
9292
*/
93-
public function offsetUnset($key)
93+
public function offsetUnset($key): void
9494
{
9595
unset($this->_elements[$key]);
9696
}
@@ -99,9 +99,9 @@ public function offsetUnset($key)
9999
* Implementation of ArrayAccess:offsetExists()
100100
*
101101
* @param mixed $key
102-
* @return boolean
102+
* @return bool
103103
*/
104-
public function offsetExists($key)
104+
public function offsetExists($key): bool
105105
{
106106
return isset($this->_elements[$key]);
107107
}
@@ -179,7 +179,7 @@ public function remove($elementId)
179179
*
180180
* @return int
181181
*/
182-
public function count()
182+
public function count(): int
183183
{
184184
return count($this->_elements);
185185
}

lib/Varien/Data/Tree/Node/Collection.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getNodes()
5959
/**
6060
* Implementation of IteratorAggregate::getIterator()
6161
*/
62-
public function getIterator()
62+
public function getIterator(): \Traversable
6363
{
6464
return new ArrayIterator($this->_nodes);
6565
}
@@ -69,17 +69,17 @@ public function getIterator()
6969
* @param string $key
7070
* @param string $value
7171
*/
72-
public function offsetSet($key, $value)
72+
public function offsetSet($key, $value): void
7373
{
7474
$this->_nodes[$key] = $value;
7575
}
7676

7777
/**
7878
* Implementation of ArrayAccess:offsetGet()
7979
* @param string $key
80-
* @return Varien_Data_Tree_Node
80+
* @return mixed|Varien_Data_Tree_Node
8181
*/
82-
public function offsetGet($key)
82+
public function offsetGet($key): mixed
8383
{
8484
return $this->_nodes[$key];
8585
}
@@ -88,7 +88,7 @@ public function offsetGet($key)
8888
* Implementation of ArrayAccess:offsetUnset()
8989
* @param string $key
9090
*/
91-
public function offsetUnset($key)
91+
public function offsetUnset($key): void
9292
{
9393
unset($this->_nodes[$key]);
9494
}
@@ -98,7 +98,7 @@ public function offsetUnset($key)
9898
* @param string $key
9999
* @return bool
100100
*/
101-
public function offsetExists($key)
101+
public function offsetExists($key): bool
102102
{
103103
return isset($this->_nodes[$key]);
104104
}
@@ -139,7 +139,7 @@ public function delete($node)
139139
*
140140
* @return int
141141
*/
142-
public function count()
142+
public function count(): int
143143
{
144144
return count($this->_nodes);
145145
}

lib/Varien/Db/Tree/NodeSet.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
/**
2323
* TODO implements iterators
24-
*
2524
*/
2625
class Varien_Db_Tree_NodeSet implements Iterator
2726
{
@@ -60,31 +59,32 @@ public function count()
6059
/**
6160
* @return bool
6261
*/
63-
public function valid()
62+
public function valid(): bool
6463
{
6564
return isset($this->_nodes[$this->_current]);
6665
}
6766

67+
#[\ReturnTypeWillChange]
6868
public function next()
6969
{
7070
if ($this->_current > $this->_currentNode) {
7171
return false;
7272
} else {
73-
return $this->_current++;
73+
return $this->_current++;
7474
}
7575
}
7676

77-
public function key()
77+
public function key(): mixed
7878
{
7979
return $this->_current;
8080
}
8181

82-
public function current()
82+
public function current(): mixed
8383
{
8484
return $this->_nodes[$this->_current];
8585
}
8686

87-
public function rewind()
87+
public function rewind(): void
8888
{
8989
$this->_current = 0;
9090
}

lib/Varien/Object.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,7 @@ public function debug($data = null, &$objects = [])
836836
* @param string $offset
837837
* @param mixed $value
838838
*/
839-
#[ReturnTypeWillChange]
840-
public function offsetSet($offset, $value)
839+
public function offsetSet($offset, $value): void
841840
{
842841
$this->_data[$offset] = $value;
843842
}
@@ -847,10 +846,9 @@ public function offsetSet($offset, $value)
847846
*
848847
* @link http://www.php.net/manual/en/arrayaccess.offsetexists.php
849848
* @param string $offset
850-
* @return boolean
849+
* @return bool
851850
*/
852-
#[ReturnTypeWillChange]
853-
public function offsetExists($offset)
851+
public function offsetExists($offset): bool
854852
{
855853
return isset($this->_data[$offset]);
856854
}
@@ -861,8 +859,7 @@ public function offsetExists($offset)
861859
* @link http://www.php.net/manual/en/arrayaccess.offsetunset.php
862860
* @param string $offset
863861
*/
864-
#[ReturnTypeWillChange]
865-
public function offsetUnset($offset)
862+
public function offsetUnset($offset): void
866863
{
867864
unset($this->_data[$offset]);
868865
}
@@ -874,8 +871,7 @@ public function offsetUnset($offset)
874871
* @param string $offset
875872
* @return mixed
876873
*/
877-
#[ReturnTypeWillChange]
878-
public function offsetGet($offset)
874+
public function offsetGet($offset): mixed
879875
{
880876
return isset($this->_data[$offset]) ? $this->_data[$offset] : null;
881877
}

0 commit comments

Comments
 (0)