{"record":{"id":"90b67129578a0e4d","repo":"pestphp/pest","slug":"the-after-hook-may-only-be-chained-onto-beforee","errorCode":null,"errorMessage":"The [after] hook may only be chained onto [beforeEach] inside a [describe] block. Please move it inside one in [%s].","messagePattern":"The \\[after\\] hook may only be chained onto \\[beforeEach\\] inside a \\[describe\\] block\\. Please move it inside one in \\[(.+?)\\]\\.","errorType":"exception","errorClass":"AfterBeforeTestFunction","httpStatus":null,"severity":"error","filePath":"src/PendingCalls/BeforeEachCall.php","lineNumber":83,"sourceCode":"        $beforeEachTestCase = ChainableClosure::boundWhen(\n            fn (): bool => $describing === [] || in_array(Arr::last($describing), $this->__describing, true),\n            ChainableClosure::bound(fn () => $testCaseProxies->chain($this), $this->closure)->bindTo($this, self::class),\n        )->bindTo($this, self::class);\n\n        assert($beforeEachTestCase instanceof Closure);\n\n        $this->testSuite->beforeEach->set(\n            $this->filename,\n            $this,\n            $beforeEachTestCall,\n            $beforeEachTestCase,\n        );\n    }\n\n    public function after(Closure $closure): self\n    {\n        if ($this->describing === []) {\n            throw new AfterBeforeTestFunction($this->filename);\n        }\n\n        return $this->__call('after', [$closure]);\n    }\n\n    /**\n     * @param  array<int, mixed>  $arguments\n     */\n    public function __call(string $name, array $arguments): self\n    {\n        if (method_exists(TestCall::class, $name)) {\n            $this->testCallProxies\n                ->add(Backtrace::file(), Backtrace::line(), $name, $arguments);\n\n            return $this;\n        }\n\n        $this->testCaseProxies","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/pestphp/pest/blob/1af74a215c3a89bc7a44fc6f9322e369eaad2423/src/PendingCalls/BeforeEachCall.php#L65-L101","documentation":"Error \"The [after] hook may only be chained onto [beforeEach] inside a [describe] block. Please move it inside one in [%s].\" thrown in pestphp/pest.","triggerScenarios":"Thrown at src/PendingCalls/BeforeEachCall.php:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1af74a215c3a89bc7a44fc6f9322e369eaad2423","analyzedAt":"2026-08-21T02:16:38.132Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}