Skip to content

Commit

Permalink
Add original function name to FAUX_FUNCTION to avoid potential clashes
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm authored and ondrejmirtes committed Sep 21, 2022
1 parent 463e931 commit c8cd404
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,9 @@ private static function getExpressionResolvers(): array
];

foreach (['contains', 'startsWith', 'endsWith'] as $name) {
self::$resolvers[$name] = static function (Scope $scope, Arg $value, Arg $subString): array {
self::$resolvers[$name] = static function (Scope $scope, Arg $value, Arg $subString) use ($name): array {
if ($scope->getType($subString->value)->isNonEmptyString()->yes()) {
return self::createIsNonEmptyStringAndSomethingExprPair([$value, $subString]);
return self::createIsNonEmptyStringAndSomethingExprPair($name, [$value, $subString]);
}

return [self::$resolvers['string']($scope, $value), null];
Expand All @@ -764,8 +764,8 @@ private static function getExpressionResolvers(): array
'notWhitespaceOnly',
];
foreach ($assertionsResultingAtLeastInNonEmptyString as $name) {
self::$resolvers[$name] = static function (Scope $scope, Arg $value): array {
return self::createIsNonEmptyStringAndSomethingExprPair([$value]);
self::$resolvers[$name] = static function (Scope $scope, Arg $value) use ($name): array {
return self::createIsNonEmptyStringAndSomethingExprPair($name, [$value]);
};
}

Expand Down Expand Up @@ -956,7 +956,7 @@ static function (?ArrayItem $item) use ($scope, $value, $resolver) {
* @param Arg[] $args
* @return array{Expr, Expr}
*/
private static function createIsNonEmptyStringAndSomethingExprPair(array $args): array
private static function createIsNonEmptyStringAndSomethingExprPair(string $name, array $args): array
{
$expr = new BooleanAnd(
new FuncCall(
Expand All @@ -971,7 +971,7 @@ private static function createIsNonEmptyStringAndSomethingExprPair(array $args):

$rootExpr = new BooleanAnd(
$expr,
new FuncCall(new Name('FAUX_FUNCTION'), $args)
new FuncCall(new Name('FAUX_FUNCTION_ ' . $name), $args)
);

return [$expr, $rootExpr];
Expand Down

0 comments on commit c8cd404

Please sign in to comment.