{"record":{"id":"fbfbbeb6342e023c","repo":"nikic/PHP-Parser","slug":"can-only-use-getstmts-on-a-set-hook-if-the-pr","errorCode":null,"errorMessage":"Can only use getStmts() on a \"set\" hook if the \"propertyName\" attribute is set","messagePattern":"Can only use getStmts\\(\\) on a \"set\" hook if the \"propertyName\" attribute is set","errorType":"exception","errorClass":"\\LogicException","httpStatus":null,"severity":"error","filePath":"lib/PhpParser/Node/PropertyHook.php","lineNumber":81,"sourceCode":"        return null;\n    }\n\n    /**\n     * Whether the property hook is final.\n     */\n    public function isFinal(): bool {\n        return (bool) ($this->flags & Modifiers::FINAL);\n    }\n\n    public function getStmts(): ?array {\n        if ($this->body instanceof Expr) {\n            $name = $this->name->toLowerString();\n            if ($name === 'get') {\n                return [new Return_($this->body)];\n            }\n            if ($name === 'set') {\n                if (!$this->hasAttribute('propertyName')) {\n                    throw new \\LogicException(\n                        'Can only use getStmts() on a \"set\" hook if the \"propertyName\" attribute is set');\n                }\n\n                $propName = $this->getAttribute('propertyName');\n                $prop = new PropertyFetch(new Variable('this'), (string) $propName);\n                return [new Expression(new Assign($prop, $this->body))];\n            }\n            throw new \\LogicException('Unknown property hook \"' . $name . '\"');\n        }\n        return $this->body;\n    }\n\n    public function getAttrGroups(): array {\n        return $this->attrGroups;\n    }\n\n    public function getType(): string {\n        return 'PropertyHook';","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/nikic/PHP-Parser/blob/fbd47f7ebcbb450138d92642a0a53b72a5285dda/lib/PhpParser/Node/PropertyHook.php#L63-L99","documentation":"Error \"Can only use getStmts() on a \"set\" hook if the \"propertyName\" attribute is set\" thrown in nikic/PHP-Parser.","triggerScenarios":"Thrown at lib/PhpParser/Node/PropertyHook.php:81 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":"fbd47f7ebcbb450138d92642a0a53b72a5285dda","analyzedAt":"2026-08-17T03:58:32.123Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}