Skip to content

Commit e348ad8

Browse files
committed
Suppressing return type compatibility error as of php 8.1+
1 parent 102a1c8 commit e348ad8

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

AbstractEmbeddedBehavior.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ public function __get($name)
9191
{
9292
if ($this->checkName($name)) {
9393
return $this->storage;
94-
} else {
95-
return parent::__get($name);
9694
}
95+
96+
return parent::__get($name);
9797
}
9898

9999
public function __set($name, $value)

EmbeddedDocument.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class EmbeddedDocument extends Model
3333
/**
3434
* @inheritdoc
3535
*/
36+
#[\ReturnTypeWillChange]
3637
public function formName()
3738
{
3839
if (!empty($this->_formName)) {
@@ -45,6 +46,7 @@ public function formName()
4546
/**
4647
* @param $formName
4748
*/
49+
#[\ReturnTypeWillChange]
4850
public function setFormName($formName)
4951
{
5052
if (!empty($formName)) {
@@ -56,6 +58,7 @@ public function setFormName($formName)
5658
* set link to primary model
5759
* @param ActiveRecord $model
5860
*/
61+
#[\ReturnTypeWillChange]
5962
public function setPrimaryModel(ActiveRecord $model)
6063
{
6164
$this->_primaryModel = $model;
@@ -66,6 +69,7 @@ public function setPrimaryModel(ActiveRecord $model)
6669
* @return ActiveRecord
6770
* @throws UnknownPropertyException
6871
*/
72+
#[\ReturnTypeWillChange]
6973
public function getPrimaryModel()
7074
{
7175
if (!isset($this->_primaryModel)) {
@@ -79,6 +83,7 @@ public function getPrimaryModel()
7983
* set link to primary model attribute
8084
* @param $value
8185
*/
86+
#[\ReturnTypeWillChange]
8287
public function setSource($value)
8388
{
8489
$this->_source = $value;
@@ -88,6 +93,7 @@ public function setSource($value)
8893
* Save embedded model as attribute on primary model
8994
* @throws UnknownPropertyException
9095
*/
96+
#[\ReturnTypeWillChange]
9197
public function save()
9298
{
9399
if (!isset($this->_source) || !$this->primaryModel->hasAttribute($this->_source)) {
@@ -96,6 +102,7 @@ public function save()
96102
$this->primaryModel->save(false, [$this->_source]);
97103
}
98104

105+
#[\ReturnTypeWillChange]
99106
public function setScenario($scenario)
100107
{
101108
if (array_key_exists($scenario, $this->scenarios())) {
@@ -111,6 +118,7 @@ public function setScenario($scenario)
111118
* Пустым считается объект все атрибуты которого пусты (empty($value)) или равны значениям по-умолчанию. Не учитывает параметры "when" и "isEmpty" валидаторов "по-умолчанию".
112119
* @return bool
113120
*/
121+
#[\ReturnTypeWillChange]
114122
public function isEmpty()
115123
{
116124
$notEmptyAttributes = [];

EmbedsManyBehavior.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ class EmbedsManyBehavior extends AbstractEmbeddedBehavior
1515
{
1616
public $initEmptyScenarios = [];
1717

18+
#[\ReturnTypeWillChange]
1819
public function getFormName($index)
1920
{
2021
if ($this->setFormName) {
2122
return Html::getInputName($this->owner, $this->fakeAttribute."[{$index}]");
22-
} else {
23-
return null;
2423
}
24+
25+
return null;
2526
}
2627

2728
/**
2829
* @inheritdoc
2930
*/
31+
#[\ReturnTypeWillChange]
3032
protected function setAttributes($attributes, $safeOnly = true)
3133
{
3234
$this->storage->removeAll();
@@ -51,6 +53,7 @@ protected function setAttributes($attributes, $safeOnly = true)
5153
/**
5254
* @inheritdoc
5355
*/
56+
#[\ReturnTypeWillChange]
5457
protected function getAttributes()
5558
{
5659
return $this->storage->attributes;
@@ -59,6 +62,7 @@ protected function getAttributes()
5962
/**
6063
* @return Storage
6164
*/
65+
#[\ReturnTypeWillChange]
6266
public function getStorage()
6367
{
6468
if (empty($this->_storage)) {

EmbedsOneBehavior.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
class EmbedsOneBehavior extends AbstractEmbeddedBehavior
1313
{
14+
#[\ReturnTypeWillChange]
1415
protected function setAttributes($attributes, $safeOnly = true)
1516
{
1617
$this->storage->scenario = $this->owner->scenario;
@@ -20,18 +21,20 @@ protected function setAttributes($attributes, $safeOnly = true)
2021
/**
2122
* @inheritdoc
2223
*/
24+
#[\ReturnTypeWillChange]
2325
protected function getAttributes()
2426
{
2527
if ($this->saveEmpty || !$this->storage->isEmpty()) {
2628
return $this->storage->attributes;
27-
} else {
28-
return null;
2929
}
30+
31+
return null;
3032
}
3133

3234
/**
3335
* @return EmbeddedDocument
3436
*/
37+
#[\ReturnTypeWillChange]
3538
public function getStorage()
3639
{
3740
if (empty($this->_storage)) {

Storage.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Storage extends Component implements StorageInterface, \Countable, \Iterat
1717

1818
private $_cursor = 0;
1919

20+
#[\ReturnTypeWillChange]
2021
public function removeAll()
2122
{
2223
$this->_container = [];
@@ -27,6 +28,7 @@ public function removeAll()
2728
* @param string $name
2829
* @param Event $event
2930
*/
31+
#[\ReturnTypeWillChange]
3032
public function trigger($name, Event $event = null)
3133
{
3234
parent::trigger($name, $event);
@@ -39,6 +41,7 @@ public function trigger($name, Event $event = null)
3941
/**
4042
* @inheritdoc
4143
*/
44+
#[\ReturnTypeWillChange]
4245
public function validate()
4346
{
4447
$hasError = false;
@@ -54,6 +57,7 @@ public function validate()
5457
/**
5558
* @inheritdoc
5659
*/
60+
#[\ReturnTypeWillChange]
5761
public function getAttributes()
5862
{
5963
$attributes = [];
@@ -69,6 +73,7 @@ public function getAttributes()
6973
* @param $condition
7074
* @return null| EmbeddedDocument
7175
*/
76+
#[\ReturnTypeWillChange]
7277
public function get($condition)
7378
{
7479
list($attribute, $value) = $condition;
@@ -87,6 +92,7 @@ public function get($condition)
8792
* @param $object
8893
* @return bool
8994
*/
95+
#[\ReturnTypeWillChange]
9096
public function set($condition, $object)
9197
{
9298
list($attribute, $value) = $condition;
@@ -100,6 +106,7 @@ public function set($condition, $object)
100106
return false;
101107
}
102108

109+
#[\ReturnTypeWillChange]
103110
public function sort($field)
104111
{
105112
$attributes = $this->attributes;
@@ -111,6 +118,7 @@ public function sort($field)
111118
});
112119
}
113120

121+
#[\ReturnTypeWillChange]
114122
public function offsetSet($offset, $model)
115123
{
116124
if (is_null($offset)) {
@@ -120,6 +128,7 @@ public function offsetSet($offset, $model)
120128
$this->_container[$offset] = $model;
121129
}
122130

131+
#[\ReturnTypeWillChange]
123132
public function current()
124133
{
125134
if ($this->valid($this->_cursor)) {
@@ -129,47 +138,56 @@ public function current()
129138
}
130139
}
131140

141+
#[\ReturnTypeWillChange]
132142
public function key()
133143
{
134144
return $this->_cursor;
135145
}
136146

147+
#[\ReturnTypeWillChange]
137148
public function next()
138149
{
139150
++$this->_cursor;
140151
}
141152

153+
#[\ReturnTypeWillChange]
142154
public function rewind()
143155
{
144156
$this->_cursor = 0;
145157
}
146158

159+
#[\ReturnTypeWillChange]
147160
public function valid()
148161
{
149162
return $this->offsetExists($this->_cursor);
150163
}
151164

165+
#[\ReturnTypeWillChange]
152166
public function offsetExists($offset)
153167
{
154168
return isset($this->_container[$offset]);
155169
}
156170

171+
#[\ReturnTypeWillChange]
157172
public function offsetUnset($offset)
158173
{
159174
unset($this->_container[$offset]);
160175
$this->_container = array_values($this->_container);
161176
}
162177

178+
#[\ReturnTypeWillChange]
163179
public function offsetGet($offset)
164180
{
165181
return isset($this->_container[$offset]) ? $this->_container[$offset] : null;
166182
}
167183

184+
#[\ReturnTypeWillChange]
168185
public function count()
169186
{
170187
return count($this->_container);
171188
}
172189

190+
#[\ReturnTypeWillChange]
173191
public function getNextIndex()
174192
{
175193
$count = count($this->_container);
@@ -181,6 +199,7 @@ public function getNextIndex()
181199
* @param string $scenario
182200
* @return void
183201
*/
202+
#[\ReturnTypeWillChange]
184203
public function setScenario($scenario)
185204
{
186205
foreach ($this->_container as $model) {
@@ -189,6 +208,7 @@ public function setScenario($scenario)
189208
}
190209
}
191210

211+
#[\ReturnTypeWillChange]
192212
public function __toString()
193213
{
194214
return '';

StorageInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface StorageInterface extends \ArrayAccess
1414
/**
1515
* Triggers an event
1616
* @param string $name the event name
17-
* @param Event $event the event parameter. If not set, a default [[Event]] object will be created.
17+
* @param Event|null $event the event parameter. If not set, a default [[Event]] object will be created.
1818
*/
1919
public function trigger($name, Event $event = null);
2020

0 commit comments

Comments
 (0)