Skip to content

Fix dynamic return type extension for has_filter()/has_action()#151

Merged
szepeviktor merged 1 commit intoszepeviktor:masterfrom
IanDelMar:has-filter
Feb 25, 2023
Merged

Fix dynamic return type extension for has_filter()/has_action()#151
szepeviktor merged 1 commit intoszepeviktor:masterfrom
IanDelMar:has-filter

Conversation

@IanDelMar
Copy link
Copy Markdown
Contributor

This PR fixes the return type of has_filter() and has_action() for maybe false types.

A maybe false type such as callable|string|array|false is not an instance of MixedType in

if ($callbackArgumentType instanceof MixedType) {
return TypeCombinator::union(
new BooleanType(),
new IntegerType()
);
}

Failing test:

// Maybe false callback
/** @var callable|string|array|false $callback */
$callback = $_GET['callback'];
assertType('bool|int', has_filter('', $callback));
assertType('bool|int', has_action('', $callback));

This PR also replaces a deprecated instanceof ConstantBooleanType.

@szepeviktor szepeviktor merged commit 0515722 into szepeviktor:master Feb 25, 2023
@IanDelMar IanDelMar deleted the has-filter branch February 25, 2023 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants