Skip to content

Commit 567b4b7

Browse files
committed
Fix deprecated warnings for 8.1
For real this time!
1 parent 347cd44 commit 567b4b7

File tree

4 files changed

+14
-60
lines changed

4 files changed

+14
-60
lines changed

src/xPDO/Validation/xPDOValidator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public function validate(array $parameters = array()) {
6565
}
6666
break;
6767
case 'preg_match':
68-
$result= (boolean) preg_match($rule['rule'], $this->object->_fields[$column]);
68+
if (is_null($this->object->_fields[$column])) {
69+
$result = false;
70+
} else {
71+
$result = (boolean)preg_match($rule['rule'], $this->object->_fields[$column]);
72+
}
6973
if (!$result) $this->addMessage($column, $ruleName, isset($rule['parameters']['message']) ? $rule['parameters']['message'] : $ruleName . ' failed');
7074
if ($this->object->xpdo->getDebug() === true)
7175
$this->object->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "preg_match validation against {$rule['rule']} resulted in " . print_r($result, 1));

src/xPDO/xPDOContainer.php

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -74,75 +74,22 @@ public function has(string $id): bool
7474
return $this->offsetExists($id);
7575
}
7676

77-
/**
78-
* Whether an offset exists
79-
*
80-
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
81-
*
82-
* @param mixed $offset <p>
83-
* An offset to check for.
84-
* </p>
85-
*
86-
* @return bool true on success or false on failure.
87-
* </p>
88-
* <p>
89-
* The return value will be cast to boolean if non-boolean was returned.
90-
* @since 5.0.0
91-
*/
9277
public function offsetExists($offset): bool
9378
{
9479
return array_key_exists($offset, $this->entries);
9580
}
9681

97-
/**
98-
* Offset to retrieve
99-
*
100-
* @link http://php.net/manual/en/arrayaccess.offsetget.php
101-
*
102-
* @param mixed $offset <p>
103-
* The offset to retrieve.
104-
* </p>
105-
*
106-
* @return mixed Can return all value types.
107-
* @since 5.0.0
108-
*/
82+
#[\ReturnTypeWillChange]
10983
public function offsetGet($offset)
11084
{
11185
return $this->entries[$offset];
11286
}
11387

114-
/**
115-
* Offset to set
116-
*
117-
* @link http://php.net/manual/en/arrayaccess.offsetset.php
118-
*
119-
* @param mixed $offset <p>
120-
* The offset to assign the value to.
121-
* </p>
122-
* @param mixed $value <p>
123-
* The value to set.
124-
* </p>
125-
*
126-
* @return void
127-
* @since 5.0.0
128-
*/
12988
public function offsetSet($offset, $value): void
13089
{
13190
$this->entries[$offset] = $value;
13291
}
13392

134-
/**
135-
* Offset to unset
136-
*
137-
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
138-
*
139-
* @param mixed $offset <p>
140-
* The offset to unset.
141-
* </p>
142-
*
143-
* @return void
144-
* @since 5.0.0
145-
*/
14693
public function offsetUnset($offset): void
14794
{
14895
unset($this->entries[$offset]);

src/xPDO/xPDOIterator.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(xPDO &$xpdo, array $options = [])
7878
return $this;
7979
}
8080

81-
public function rewind()
81+
public function rewind(): void
8282
{
8383
$this->index = 0;
8484
if (!empty($this->stmt)) {
@@ -96,25 +96,27 @@ public function rewind()
9696
}
9797
}
9898

99+
#[\ReturnTypeWillChange]
99100
public function current()
100101
{
101102
return $this->current;
102103
}
103104

105+
#[\ReturnTypeWillChange]
104106
public function key()
105107
{
106108
return $this->index;
107109
}
108110

109-
public function next()
111+
#[TentativeType]
112+
public function next(): void
110113
{
111114
$this->fetch();
112115
if (!$this->valid()) {
113116
$this->index = null;
114117
} else {
115118
$this->index++;
116119
}
117-
return $this->current();
118120
}
119121

120122
public function valid(): bool

src/xPDO/xPDOMap.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function offsetExists($offset): bool
3838
return isset($this->map[$offset]);
3939
}
4040

41+
#[\ReturnTypeWillChange]
4142
public function offsetGet($offset)
4243
{
4344
if (!isset($this->map[$offset])) {
@@ -46,12 +47,12 @@ public function offsetGet($offset)
4647
return $this->map[$offset];
4748
}
4849

49-
public function offsetSet($offset, $value)
50+
public function offsetSet($offset, $value): void
5051
{
5152
$this->map[$offset] = $value;
5253
}
5354

54-
public function offsetUnset($offset)
55+
public function offsetUnset($offset): void
5556
{
5657
unset($this->map[$offset]);
5758
}

0 commit comments

Comments
 (0)