Skip to content

Commit 60a78ce

Browse files
authored
Merge pull request #768 from ausi/fix/php-8-1-compat
Fix PHP 8.1 deprecations
2 parents 5da0c38 + a73e056 commit 60a78ce

File tree

6 files changed

+42
-1
lines changed

6 files changed

+42
-1
lines changed

src/Gd/Drawer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,11 @@ public function polygon(array $coordinates, ColorInterface $color, $fill = false
331331
throw new RuntimeException('Draw polygon operation failed');
332332
}
333333

334-
if (false === $callback($this->resource, $points, count($coordinates), $this->getColor($color))) {
334+
if (false === (
335+
PHP_VERSION_ID < 80000
336+
? $callback($this->resource, $points, count($coordinates), $this->getColor($color))
337+
: $callback($this->resource, $points, $this->getColor($color))
338+
)) {
335339
imagealphablending($this->resource, false);
336340
throw new RuntimeException('Draw polygon operation failed');
337341
}

src/Gd/Layers.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function animate($format, $delay, $loops)
9494
*
9595
* @see \Iterator::current()
9696
*/
97+
#[\ReturnTypeWillChange]
9798
public function current()
9899
{
99100
return $this->getClassFactory()->createImage(ClassFactoryInterface::HANDLE_GD, $this->resource, $this->palette, new MetadataBag());
@@ -104,6 +105,7 @@ public function current()
104105
*
105106
* @see \Iterator::key()
106107
*/
108+
#[\ReturnTypeWillChange]
107109
public function key()
108110
{
109111
return $this->offset;
@@ -114,6 +116,7 @@ public function key()
114116
*
115117
* @see \Iterator::next()
116118
*/
119+
#[\ReturnTypeWillChange]
117120
public function next()
118121
{
119122
++$this->offset;
@@ -124,6 +127,7 @@ public function next()
124127
*
125128
* @see \Iterator::rewind()
126129
*/
130+
#[\ReturnTypeWillChange]
127131
public function rewind()
128132
{
129133
$this->offset = 0;
@@ -134,6 +138,7 @@ public function rewind()
134138
*
135139
* @see \Iterator::valid()
136140
*/
141+
#[\ReturnTypeWillChange]
137142
public function valid()
138143
{
139144
return $this->offset < 1;
@@ -144,6 +149,7 @@ public function valid()
144149
*
145150
* @see \Countable::count()
146151
*/
152+
#[\ReturnTypeWillChange]
147153
public function count()
148154
{
149155
return 1;
@@ -154,6 +160,7 @@ public function count()
154160
*
155161
* @see \ArrayAccess::offsetExists()
156162
*/
163+
#[\ReturnTypeWillChange]
157164
public function offsetExists($offset)
158165
{
159166
return 0 === $offset;
@@ -164,6 +171,7 @@ public function offsetExists($offset)
164171
*
165172
* @see \ArrayAccess::offsetGet()
166173
*/
174+
#[\ReturnTypeWillChange]
167175
public function offsetGet($offset)
168176
{
169177
if (0 === $offset) {
@@ -178,6 +186,7 @@ public function offsetGet($offset)
178186
*
179187
* @see \ArrayAccess::offsetSet()
180188
*/
189+
#[\ReturnTypeWillChange]
181190
public function offsetSet($offset, $value)
182191
{
183192
throw new NotSupportedException('GD does not support layer set');
@@ -188,6 +197,7 @@ public function offsetSet($offset, $value)
188197
*
189198
* @see \ArrayAccess::offsetUnset()
190199
*/
200+
#[\ReturnTypeWillChange]
191201
public function offsetUnset($offset)
192202
{
193203
throw new NotSupportedException('GD does not support layer unset');

src/Gmagick/Layers.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public function animate($format, $delay, $loops)
130130
*
131131
* @see \Iterator::current()
132132
*/
133+
#[\ReturnTypeWillChange]
133134
public function current()
134135
{
135136
return $this->extractAt($this->offset);
@@ -163,6 +164,7 @@ private function extractAt($offset)
163164
*
164165
* @see \Iterator::key()
165166
*/
167+
#[\ReturnTypeWillChange]
166168
public function key()
167169
{
168170
return $this->offset;
@@ -173,6 +175,7 @@ public function key()
173175
*
174176
* @see \Iterator::next()
175177
*/
178+
#[\ReturnTypeWillChange]
176179
public function next()
177180
{
178181
++$this->offset;
@@ -183,6 +186,7 @@ public function next()
183186
*
184187
* @see \Iterator::rewind()
185188
*/
189+
#[\ReturnTypeWillChange]
186190
public function rewind()
187191
{
188192
$this->offset = 0;
@@ -193,6 +197,7 @@ public function rewind()
193197
*
194198
* @see \Iterator::valid()
195199
*/
200+
#[\ReturnTypeWillChange]
196201
public function valid()
197202
{
198203
return $this->offset < count($this);
@@ -203,6 +208,7 @@ public function valid()
203208
*
204209
* @see \Countable::count()
205210
*/
211+
#[\ReturnTypeWillChange]
206212
public function count()
207213
{
208214
try {
@@ -217,6 +223,7 @@ public function count()
217223
*
218224
* @see \ArrayAccess::offsetExists()
219225
*/
226+
#[\ReturnTypeWillChange]
220227
public function offsetExists($offset)
221228
{
222229
return is_int($offset) && $offset >= 0 && $offset < count($this);
@@ -227,6 +234,7 @@ public function offsetExists($offset)
227234
*
228235
* @see \ArrayAccess::offsetGet()
229236
*/
237+
#[\ReturnTypeWillChange]
230238
public function offsetGet($offset)
231239
{
232240
return $this->extractAt($offset);
@@ -237,6 +245,7 @@ public function offsetGet($offset)
237245
*
238246
* @see \ArrayAccess::offsetSet()
239247
*/
248+
#[\ReturnTypeWillChange]
240249
public function offsetSet($offset, $image)
241250
{
242251
if (!$image instanceof Image) {
@@ -290,6 +299,7 @@ public function offsetSet($offset, $image)
290299
*
291300
* @see \ArrayAccess::offsetUnset()
292301
*/
302+
#[\ReturnTypeWillChange]
293303
public function offsetUnset($offset)
294304
{
295305
try {

src/Image/Histogram/Bucket.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function add($value)
5353
/**
5454
* @return int the number of elements in the bucket
5555
*/
56+
#[\ReturnTypeWillChange]
5657
public function count()
5758
{
5859
return $this->count;

src/Image/Metadata/MetadataBag.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function get($key, $default = null)
4747
*
4848
* @see \Countable::count()
4949
*/
50+
#[\ReturnTypeWillChange]
5051
public function count()
5152
{
5253
return count($this->data);
@@ -57,6 +58,7 @@ public function count()
5758
*
5859
* @see \IteratorAggregate::getIterator()
5960
*/
61+
#[\ReturnTypeWillChange]
6062
public function getIterator()
6163
{
6264
return new \ArrayIterator($this->data);
@@ -67,6 +69,7 @@ public function getIterator()
6769
*
6870
* @see \ArrayAccess::offsetExists()
6971
*/
72+
#[\ReturnTypeWillChange]
7073
public function offsetExists($offset)
7174
{
7275
return array_key_exists($offset, $this->data);
@@ -77,6 +80,7 @@ public function offsetExists($offset)
7780
*
7881
* @see \ArrayAccess::offsetSet()
7982
*/
83+
#[\ReturnTypeWillChange]
8084
public function offsetSet($offset, $value)
8185
{
8286
$this->data[$offset] = $value;
@@ -87,6 +91,7 @@ public function offsetSet($offset, $value)
8791
*
8892
* @see \ArrayAccess::offsetUnset()
8993
*/
94+
#[\ReturnTypeWillChange]
9095
public function offsetUnset($offset)
9196
{
9297
unset($this->data[$offset]);
@@ -97,6 +102,7 @@ public function offsetUnset($offset)
97102
*
98103
* @see \ArrayAccess::offsetGet()
99104
*/
105+
#[\ReturnTypeWillChange]
100106
public function offsetGet($offset)
101107
{
102108
return $this->get($offset);

src/Imagick/Layers.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public function coalesce()
141141
*
142142
* @see \Iterator::current()
143143
*/
144+
#[\ReturnTypeWillChange]
144145
public function current()
145146
{
146147
return $this->extractAt($this->offset);
@@ -174,6 +175,7 @@ private function extractAt($offset)
174175
*
175176
* @see \Iterator::key()
176177
*/
178+
#[\ReturnTypeWillChange]
177179
public function key()
178180
{
179181
return $this->offset;
@@ -184,6 +186,7 @@ public function key()
184186
*
185187
* @see \Iterator::next()
186188
*/
189+
#[\ReturnTypeWillChange]
187190
public function next()
188191
{
189192
++$this->offset;
@@ -194,6 +197,7 @@ public function next()
194197
*
195198
* @see \Iterator::rewind()
196199
*/
200+
#[\ReturnTypeWillChange]
197201
public function rewind()
198202
{
199203
$this->offset = 0;
@@ -204,6 +208,7 @@ public function rewind()
204208
*
205209
* @see \Iterator::valid()
206210
*/
211+
#[\ReturnTypeWillChange]
207212
public function valid()
208213
{
209214
return $this->offset < count($this);
@@ -214,6 +219,7 @@ public function valid()
214219
*
215220
* @see \Countable::count()
216221
*/
222+
#[\ReturnTypeWillChange]
217223
public function count()
218224
{
219225
try {
@@ -228,6 +234,7 @@ public function count()
228234
*
229235
* @see \ArrayAccess::offsetExists()
230236
*/
237+
#[\ReturnTypeWillChange]
231238
public function offsetExists($offset)
232239
{
233240
return is_int($offset) && $offset >= 0 && $offset < count($this);
@@ -238,6 +245,7 @@ public function offsetExists($offset)
238245
*
239246
* @see \ArrayAccess::offsetGet()
240247
*/
248+
#[\ReturnTypeWillChange]
241249
public function offsetGet($offset)
242250
{
243251
return $this->extractAt($offset);
@@ -248,6 +256,7 @@ public function offsetGet($offset)
248256
*
249257
* @see \ArrayAccess::offsetSet()
250258
*/
259+
#[\ReturnTypeWillChange]
251260
public function offsetSet($offset, $image)
252261
{
253262
if (!$image instanceof Image) {
@@ -290,6 +299,7 @@ public function offsetSet($offset, $image)
290299
*
291300
* @see \ArrayAccess::offsetUnset()
292301
*/
302+
#[\ReturnTypeWillChange]
293303
public function offsetUnset($offset)
294304
{
295305
try {

0 commit comments

Comments
 (0)