Skip to content

Commit df5b95b

Browse files
committed
PHP 8.2.2 compotability
1 parent 71ea544 commit df5b95b

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor/
2+
composer.lock

composer.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"name": "simplemediacode/hooks",
33
"description": "Decoupled WordPress Hooks (filters and actions)",
44
"type": "library",
5+
"version": "1.0.6",
56
"require": {
6-
"php": "~7.4|~8.0"
7+
"php": "~8.0|~8.1|~8.2"
78
},
89
"license": "GPL-2.0-only",
910
"authors": [
@@ -23,15 +24,15 @@
2324
},
2425
"minimum-stability": "stable",
2526
"keywords": [
26-
"hooks",
27-
"phphook",
28-
"phphooks",
29-
"wordpress",
30-
"php",
31-
"php7",
32-
"php8"
27+
"hooks",
28+
"phphook",
29+
"phphooks",
30+
"wordpress",
31+
"php",
32+
"php7",
33+
"php8"
3334
],
3435
"support": {
35-
"issues": "https://github.com/simplemediacode/hooks/issues"
36+
"issues": "https://github.com/simplemediacode/hooks/issues"
3637
}
37-
}
38+
}

src/WP_Hook.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22

33
namespace SimpleMediaCode\Hooks;
44

@@ -392,9 +392,12 @@ public static function build_preinitialized_hooks($filters)
392392
* @param mixed $offset An offset to check for.
393393
* @return bool True if the offset exists, false otherwise.
394394
*/
395-
public function offsetExists($offset)
395+
#[\ReturnTypeWillChange]
396+
public function offsetExists($offset): bool
396397
{
397398
return isset($this->callbacks[$offset]);
399+
// SOLUTION (not tested)
400+
// return in_array($offset, array_keys($this->callbacks, $offset), true);
398401
}
399402

400403
/**
@@ -405,7 +408,7 @@ public function offsetExists($offset)
405408
* @param mixed $offset The offset to retrieve.
406409
* @return mixed If set, the value at the specified offset, null otherwise.
407410
*/
408-
public function offsetGet($offset)
411+
public function offsetGet($offset): mixed
409412
{
410413
return isset($this->callbacks[$offset]) ? $this->callbacks[$offset] : null;
411414
}
@@ -418,7 +421,7 @@ public function offsetGet($offset)
418421
* @param mixed $offset The offset to assign the value to.
419422
* @param mixed $value The value to set.
420423
*/
421-
public function offsetSet($offset, $value)
424+
public function offsetSet($offset, $value): void
422425
{
423426
if (is_null($offset)) {
424427
$this->callbacks[] = $value;
@@ -434,7 +437,7 @@ public function offsetSet($offset, $value)
434437
*
435438
* @param mixed $offset The offset to unset.
436439
*/
437-
public function offsetUnset($offset)
440+
public function offsetUnset($offset): void
438441
{
439442
unset($this->callbacks[$offset]);
440443
}
@@ -446,7 +449,7 @@ public function offsetUnset($offset)
446449
*
447450
* @return array Of callbacks at current priority.
448451
*/
449-
public function current()
452+
public function current(): mixed
450453
{
451454
return current($this->callbacks);
452455
}
@@ -460,6 +463,7 @@ public function current()
460463
*
461464
* @return array Of callbacks at next priority.
462465
*/
466+
#[\ReturnTypeWillChange]
463467
public function next()
464468
{
465469
return next($this->callbacks);
@@ -474,7 +478,7 @@ public function next()
474478
*
475479
* @return mixed Returns current priority on success, or NULL on failure
476480
*/
477-
public function key()
481+
public function key(): mixed
478482
{
479483
return key($this->callbacks);
480484
}
@@ -488,7 +492,7 @@ public function key()
488492
*
489493
* @return bool Whether the current position is valid.
490494
*/
491-
public function valid()
495+
public function valid(): bool
492496
{
493497
return key($this->callbacks) !== null;
494498
}
@@ -500,9 +504,11 @@ public function valid()
500504
*
501505
* @link https://www.php.net/manual/en/iterator.rewind.php
502506
*/
503-
public function rewind()
507+
#[ReturnTypeWillChange]
508+
public function rewind(): void
504509
{
505510
reset($this->callbacks);
511+
//return;
506512
}
507513

508514
/**
@@ -552,4 +558,4 @@ public function wp_filter_build_unique_id($tag, $function, $priority)
552558
return $function[0] . '::' . $function[1];
553559
}
554560
}
555-
}
561+
}

0 commit comments

Comments
 (0)