Skip to content

Commit 1c22d52

Browse files
committed
feat: Fixes and tweaks
1 parent e402665 commit 1c22d52

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

Accessible_Hook_Methods.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public function __call( string $name, array $arguments ) {
5252
* @throws \BadMethodCallException If the method does not exist or is not hooked.
5353
*/
5454
public static function __callStatic( string $name, array $arguments ) {
55+
if ( 'can_initialize' === $name ) {
56+
return true;
57+
}
58+
5559
$should_throw = static::check_method_access( static::class, $name );
5660

5761
if ( false !== $should_throw ) {

Initialize.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php // phpcs:disable PHPCompatibility.Variables.ForbiddenThisUseContexts
1+
<?php // phpcs:disable PHPCompatibility.Variables.ForbiddenThisUseContexts, WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
22
/**
33
* Invoke enum file.
44
*
@@ -57,7 +57,7 @@ enum Initialize: string {
5757
* @param string|null $tag Tag to check.
5858
* @return bool
5959
*/
60-
public function is_tag_valid( ?string $tag ): bool {
60+
public function isTagValid( ?string $tag ): bool {
6161
return match ( $this ) {
6262
self::OnDemand,
6363
self::JustInTime,
@@ -67,12 +67,25 @@ public function is_tag_valid( ?string $tag ): bool {
6767
};
6868
}
6969

70+
/**
71+
* Check if the handler hooks indirectly.
72+
*
73+
* @return bool
74+
*/
75+
public function hooksIndirectly(): bool {
76+
return match ( $this ) {
77+
self::OnDemand,
78+
self::JustInTime => true,
79+
default => false,
80+
};
81+
}
82+
7083
/**
7184
* Check if the handler is initialized on demand.
7285
*
7386
* @return bool
7487
*/
75-
public function is_ondemand(): bool {
88+
public function isOnDemand(): bool {
7689
return self::OnDemand === $this;
7790
}
7891

@@ -81,7 +94,7 @@ public function is_ondemand(): bool {
8194
*
8295
* @return bool
8396
*/
84-
public function is_just_in_time(): bool {
97+
public function isJIT(): bool {
8598
return self::JustInTime === $this;
8699
}
87100
}

Invoke.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php // phpcs:disable PHPCompatibility.Variables.ForbiddenThisUseContexts, WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
22
/**
33
* Invoke enum file.
44
*
@@ -28,4 +28,22 @@ enum Invoke : string {
2828
* ! Caveat emptor: Indirect invoking can be an order of magnitude slower than direct invoking.
2929
*/
3030
case Indirectly = 'indirectly';
31+
32+
case WithCustomArgs = 'customArgs';
33+
34+
case Conditionally = 'conditionaly';
35+
36+
/**
37+
* Check if the hook is invoked indirectly.
38+
*
39+
* @return bool
40+
*/
41+
public function isIndirect(): bool {
42+
return match ( $this ) {
43+
self::Indirectly,
44+
self::Conditionally,
45+
self::WithCustomArgs => true,
46+
default => false,
47+
};
48+
}
3149
}

0 commit comments

Comments
 (0)