*/ private $state = []; /** * Sets a after each closure. */ public function set(string $filename, Closure $closure): void { if (array_key_exists($filename, $this->state)) { throw new AfterEachAlreadyExist($filename); } $this->state[$filename] = $closure; } /** * Gets a after each closure by the given filename. */ public function get(string $filename): Closure { $afterEach = $this->state[$filename] ?? NullClosure::create(); return ChainableClosure::from(function (): void { if (class_exists(Mockery::class)) { if ($container = Mockery::getContainer()) { /* @phpstan-ignore-next-line */ $this->addToAssertionCount($container->mockery_getExpectationCount()); } Mockery::close(); } }, $afterEach); } }