-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvokable.php
53 lines (47 loc) · 1.22 KB
/
Invokable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* Invokable interface file.
*
* @package eXtended WordPress
* @subpackage Contracts\Hook
*/
namespace XWP\Contracts\Hook;
use ReflectionMethod;
/**
* Invokable interface. Used by actions and filters.
*
* @template THndlr of object
*
* @property-read Invoke $strategy Invocation strategy.
* @property-read Initializable<THndlr> $handler Handler instance.
* @property-read bool $invoked Flag indicating if the hook has been invoked.
* @property-read int $args Number of arguments the hook accepts.
*
* @extends Hookable<THndlr,ReflectionMethod>
*/
interface Invokable extends Hookable {
/**
* Set the hook handler.
*
* @param Initializable<THndlr> $handler Handler instance.
* @return static
*/
public function with_handler( Initializable $handler ): static;
/**
* Set the hook target.
*
* @param string $method Method name.
* @return static
*/
public function with_target( string $method ): static;
/**
* Check if the hook can be invoked.
*
* @return bool
*/
public function can_invoke(): bool;
/**
* Invoke the hook.
*/
public function invoke();
}