Skip to content

Commit

Permalink
Remove strict typing to allow ::type( 'int' )
Browse files Browse the repository at this point in the history
`\WP_Mock\Functions::type( 'int' )`
  • Loading branch information
BrianHenryIE committed Jun 27, 2024
1 parent 22898a2 commit 7d01fcb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
12 changes: 6 additions & 6 deletions php/WP_Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,12 @@ public static function getDeprecatedMethodListener(): DeprecatedMethodListener
*
* @param string $action the action hook name
* @param string|callable-string|callable|Type $callback the callable to be removed
* @param ?int $priority the priority it should be registered at
* @param ?int|Type $priority the priority it should be registered at
*
* @return void
* @throws InvalidArgumentException
*/
public static function expectActionRemoved(string $action, $callback, ?int $priority = null) : void
public static function expectActionRemoved(string $action, $callback, $priority = null) : void

Check failure on line 560 in php/WP_Mock.php

View workflow job for this annotation

GitHub Actions / php-static-analysis

Method WP_Mock::expectActionRemoved() has parameter $priority with no type specified.

Check failure on line 560 in php/WP_Mock.php

View workflow job for this annotation

GitHub Actions / php-static-analysis

PHPDoc tag @param has invalid value (?int|Type $priority the priority it should be registered at): Unexpected token "|", expected variable at offset 228
{
self::userFunction(
'remove_action',
Expand All @@ -573,7 +573,7 @@ public static function expectActionRemoved(string $action, $callback, ?int $prio
*
* @param string $action the action hook name
* @param null|string|callable-string|callable|Type $callback the callable to be removed
* @param ?int $priority optional priority for the registered callback that is being removed
* @param ?int|Type $priority optional priority for the registered callback that is being removed
*
* @return void
* @throws InvalidArgumentException
Expand All @@ -594,12 +594,12 @@ public static function expectActionNotRemoved(string $action, $callback, $priori
*
* @param string $filter the filter name
* @param string|callable-string|callable|Type $callback the callable to be removed
* @param ?int $priority the registered priority
* @param ?int|Type $priority the registered priority
*
* @return void
* @throws InvalidArgumentException
*/
public static function expectFilterRemoved(string $filter, $callback, ?int $priority = null) : void
public static function expectFilterRemoved(string $filter, $callback, $priority = null) : void

Check failure on line 602 in php/WP_Mock.php

View workflow job for this annotation

GitHub Actions / php-static-analysis

Method WP_Mock::expectFilterRemoved() has parameter $priority with no type specified.

Check failure on line 602 in php/WP_Mock.php

View workflow job for this annotation

GitHub Actions / php-static-analysis

PHPDoc tag @param has invalid value (?int|Type $priority the registered priority): Unexpected token "|", expected variable at offset 222
{
self::userFunction(
'remove_filter',
Expand All @@ -615,7 +615,7 @@ public static function expectFilterRemoved(string $filter, $callback, ?int $prio
*
* @param string $filter the filter name
* @param null|string|callable-string|callable|Type $callback the callable to be removed
* @param ?int $priority optional priority for the registered callback that is being removed
* @param ?int|Type $priority optional priority for the registered callback that is being removed
*
* @return void
* @throws InvalidArgumentException
Expand Down
14 changes: 14 additions & 0 deletions tests/Integration/WP_MockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,26 @@ public function testCanExpectHooksRemoved() : void
WP_Mock::expectActionRemoved('wpMockTestActionWithCallbackAndPriority', 'wpMockTestFunction', 10);
WP_Mock::expectFilterRemoved('wpMockTestFilterWithCallbackAndPriority', 'wpMockTestFunction', 10);

WP_Mock::expectActionRemoved(
'wpMockTestActionWithCallbackAndAnyPriority',
'wpMockTestFunction',
\WP_Mock\Functions::type('int')
);
WP_Mock::expectFilterRemoved(
'wpMockTestFilterWithCallbackAndAnyPriority',
'wpMockTestFunction',
\WP_Mock\Functions::type('int')
);

WP_Mock::expectActionRemoved('wpMockTestActionWithCallbackAndDefaultPriority', 'wpMockTestFunction');
WP_Mock::expectFilterRemoved('wpMockTestFilterWithCallbackAndDefaultPriority', 'wpMockTestFunction');

remove_action('wpMockTestActionWithCallbackAndPriority', 'wpMockTestFunction', 10);
remove_filter('wpMockTestFilterWithCallbackAndPriority', 'wpMockTestFunction', 10);

remove_action('wpMockTestActionWithCallbackAndAnyPriority', 'wpMockTestFunction', rand(1,100));
remove_filter('wpMockTestFilterWithCallbackAndAnyPriority', 'wpMockTestFunction', rand(1,100));

remove_action('wpMockTestActionWithCallbackAndDefaultPriority', 'wpMockTestFunction');
remove_filter('wpMockTestFilterWithCallbackAndDefaultPriority', 'wpMockTestFunction');

Expand Down

0 comments on commit 7d01fcb

Please sign in to comment.