mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 02:37:22 +01:00
refacto(phpstan-to-8): few adjustments
This commit is contained in:
@ -15,11 +15,11 @@ final class Depends
|
||||
/**
|
||||
* Adds annotations regarding the "depends" feature.
|
||||
*
|
||||
* @param array<string> $annotations
|
||||
* @param array<int, string> $annotations
|
||||
*
|
||||
* @return array<string>
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function add(TestCaseMethodFactory $method, array $annotations): array
|
||||
public function __invoke(TestCaseMethodFactory $method, array $annotations): array
|
||||
{
|
||||
foreach ($method->depends as $depend) {
|
||||
$depend = Str::evaluable($depend);
|
||||
|
||||
@ -14,11 +14,11 @@ final class Groups
|
||||
/**
|
||||
* Adds annotations regarding the "groups" feature.
|
||||
*
|
||||
* @param array<string> $annotations
|
||||
* @param array<int, string> $annotations
|
||||
*
|
||||
* @return array<string>
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function add(TestCaseMethodFactory $method, array $annotations): array
|
||||
public function __invoke(TestCaseMethodFactory $method, array $annotations): array
|
||||
{
|
||||
foreach ($method->groups as $group) {
|
||||
$annotations[] = "@group $group";
|
||||
|
||||
@ -73,9 +73,9 @@ final class TestCaseFactory
|
||||
{
|
||||
$methodsUsingOnly = $this->methodsUsingOnly();
|
||||
|
||||
$methods = array_filter($this->methods, function ($method) use ($methodsUsingOnly) {
|
||||
$methods = array_values(array_filter($this->methods, function ($method) use ($methodsUsingOnly) {
|
||||
return count($methodsUsingOnly) === 0 || in_array($method, $methodsUsingOnly, true);
|
||||
});
|
||||
}));
|
||||
|
||||
if (count($methods) > 0) {
|
||||
$this->evaluate($this->filename, $methods);
|
||||
@ -99,7 +99,7 @@ final class TestCaseFactory
|
||||
/**
|
||||
* Creates a Test Case class using a runtime evaluate.
|
||||
*
|
||||
* @param array<TestCaseMethodFactory> $methods
|
||||
* @param array<int, TestCaseMethodFactory> $methods
|
||||
*/
|
||||
public function evaluate(string $filename, array $methods): string
|
||||
{
|
||||
@ -152,8 +152,8 @@ final class TestCaseFactory
|
||||
$annotations = ['@test'];
|
||||
|
||||
foreach (self::$annotations as $annotation) {
|
||||
//@phpstan-ignore-next-line
|
||||
$annotations = (new $annotation())->add($method, $annotations);
|
||||
/** @phpstan-ignore-next-line */
|
||||
$annotations = (new $annotation())->__invoke($method, $annotations);
|
||||
}
|
||||
|
||||
if (count($method->datasets) > 0) {
|
||||
|
||||
@ -89,7 +89,7 @@ final class TestCaseMethodFactory
|
||||
$testCase->chains->chain($this);
|
||||
$method->chains->chain($this);
|
||||
|
||||
return \Pest\Support\Closure::safeBind($closure, $this, $this::class)(...func_get_args());
|
||||
return \Pest\Support\Closure::bind($closure, $this, $this::class)(...func_get_args());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user