Skip to content

Commit

Permalink
Merge branch '11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 30, 2024
2 parents 49300fa + b3c1a49 commit 83c7c23
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<exec executable="${basedir}/build/scripts/generate-global-assert-wrappers.php" taskname="generate-global-assert-wrappers" failonerror="true"/>
<exec executable="${basedir}/tools/php-cs-fixer" taskname="php-cs-fixer" failonerror="true">
<arg value="fix"/>
<arg value="--show-progress=none"/>
<arg path="${basedir}/src/Framework/Assert/Functions.php"/>
</exec>
</target>
Expand Down
18 changes: 18 additions & 0 deletions build/scripts/generate-global-assert-wrappers.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@

$usedClasses[] = $returnType->getName();

// skip, so we can later on append a signature including precise analysis types
if ($method->getName() === 'callback') {
continue;
}

$constraintMethods .= \sprintf(
"if (!function_exists('PHPUnit\Framework\\" . $method->getName() . "')) {\n%s\n{\n return Assert::%s(...\\func_get_args());\n}\n}\n\n",
\str_replace('final public static ', '', \trim($lines[$method->getStartLine() - 1])),
Expand Down Expand Up @@ -105,6 +110,19 @@
$buffer .= $constraintMethods;

$buffer .= <<<'EOT'
if (!function_exists('PHPUnit\Framework\callback')) {
/**
* @psalm-template CallbackInput of mixed
*
* @psalm-param callable(CallbackInput $callback): bool $callback
*
* @psalm-return Callback<CallbackInput>
*/
function callback(callable $callback): Callback
{
return Assert::callback($callback);
}
}
if (!function_exists('PHPUnit\Framework\any')) {
/**
Expand Down
21 changes: 14 additions & 7 deletions src/Framework/Assert/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2384,13 +2384,6 @@ function isTrue(): IsTrue
}
}

if (!function_exists('PHPUnit\Framework\callback')) {
function callback(callable $callback): Callback
{
return Assert::callback(...func_get_args());
}
}

if (!function_exists('PHPUnit\Framework\isFalse')) {
function isFalse(): IsFalse
{
Expand Down Expand Up @@ -2643,6 +2636,20 @@ function objectEquals(object $object, string $method = 'equals'): ObjectEquals
}
}

if (!function_exists('PHPUnit\Framework\callback')) {
/**
* @psalm-template CallbackInput of mixed
*
* @psalm-param callable(CallbackInput $callback): bool $callback
*
* @psalm-return Callback<CallbackInput>
*/
function callback(callable $callback): Callback
{
return Assert::callback($callback);
}
}

if (!function_exists('PHPUnit\Framework\any')) {
/**
* Returns a matcher that matches when the method is executed
Expand Down

0 comments on commit 83c7c23

Please sign in to comment.