refacto(phpstan-to-8): few adjustments

This commit is contained in:
Nuno Maduro
2021-11-18 23:39:37 +00:00
parent 7ea6d8a35d
commit 94585789dc
18 changed files with 107 additions and 94 deletions

View File

@ -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);

View File

@ -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";

View File

@ -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) {

View File

@ -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());
};
}