Skip to content

Commit bfb65ab

Browse files
committed
fix: Deprecation notice
1 parent 3df2a23 commit bfb65ab

File tree

5 files changed

+31
-40
lines changed

5 files changed

+31
-40
lines changed

composer.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.1",
14-
"automattic/jetpack-constants": "^2.0",
13+
"php": ">=8.1",
14+
"automattic/jetpack-constants": "^2",
1515
"x-wp/hook-invoker": "^1"
1616
},
1717
"require-dev": {
18-
"oblak/wordpress-coding-standard": "^1.1.1"
18+
"oblak/wordpress-coding-standard": "^1"
1919
},
2020
"suggest": {
21-
"automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package.",
22-
"oblak/composer-wp-di-finder-plugin": "Automatically find Hookable classes"
21+
"automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package."
2322
},
2423
"minimum-stability": "beta",
2524
"prefer-stable": true,
@@ -34,8 +33,7 @@
3433
},
3534
"config": {
3635
"allow-plugins": {
37-
"dealerdirect/phpcodesniffer-composer-installer": true,
38-
"ergebnis/composer-normalize": true
36+
"dealerdirect/phpcodesniffer-composer-installer": true
3937
}
4038
}
4139
}

composer.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Annotation_Parser.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
/**
1818
* Annotation parser for legacy code.
19-
*
20-
* @deprecated 1.0.0
2119
*/
2220
final class Annotation_Parser {
2321
/**

src/Decorators/Hookable.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,23 @@ class Hookable extends Handler {
2424
* @param string $hook Hook name.
2525
* @param int $priority Hook priority.
2626
* @param callable $conditional Conditional callback function.
27+
* @param string $tag Tag name. Optional, if not provided, hook name will be used.
2728
* @param mixed ...$args Arguments to pass to the hookable class constructor.
29+
*
30+
* @throws \InvalidArgumentException If hook or tag is not provided.
2831
*/
2932
public function __construct(
30-
string $hook,
33+
?string $hook = null,
3134
int $priority = 10,
32-
$conditional = '__return_true',
35+
$conditional = null,
36+
?string $tag = null,
3337
mixed ...$args,
3438
) {
35-
parent::__construct( tag: $hook, priority: $priority, conditional: $conditional );
39+
$tgt = $tag ?? $hook ?? false;
40+
41+
if ( ! $tgt ) {
42+
throw new \InvalidArgumentException( 'Hook name or tag must be provided.' );
43+
}
44+
parent::__construct( tag: $tgt, priority: $priority, conditional: $conditional );
3645
}
3746
}

src/Utils/wp-hook-di-fn-loader.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)