{"record":{"id":"452d56428637b380","repo":"doctrine/annotations","slug":"the-annotation-s-declared-on-s-does-not-accept-any-values","errorCode":null,"errorMessage":"The annotation @%s declared on %s does not accept any values, but got %s.","messagePattern":"The annotation @(.+?) declared on (.+?) does not accept any values, but got (.+?)\\.","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"lib/Doctrine/Common/Annotations/DocParser.php","lineNumber":1013,"sourceCode":"            if (! isset(self::$annotationMetadata[$name]['properties'][$property])) {\n                if ($property !== 'value') {\n                    throw AnnotationException::creationError(sprintf(\n                        <<<'EXCEPTION'\nThe annotation @%s declared on %s does not have a property named \"%s\".\nAvailable properties: %s\nEXCEPTION\n                        ,\n                        $originalName,\n                        $this->context,\n                        $property,\n                        implode(', ', self::$annotationMetadata[$name]['properties'])\n                    ));\n                }\n\n                // handle the case if the property has no annotations\n                $property = self::$annotationMetadata[$name]['default_property'];\n                if (! $property) {\n                    throw AnnotationException::creationError(sprintf(\n                        'The annotation @%s declared on %s does not accept any values, but got %s.',\n                        $originalName,\n                        $this->context,\n                        json_encode($values)\n                    ));\n                }\n            }\n\n            $instance->{$property} = $value;\n        }\n\n        return $instance;\n    }\n\n    /**\n     * MethodCall ::= [\"(\" [Values] \")\"]\n     *\n     * @psalm-return Arguments","sourceCodeStart":995,"sourceCodeEnd":1031,"githubUrl":"https://github.com/doctrine/annotations/blob/17815fb6b2f4c3c701ba2abdf2c6c97b219fb2e4/lib/Doctrine/Common/Annotations/DocParser.php#L995-L1031","documentation":"When annotation values are given as a bare value (e.g. @Foo(\"bar\")) rather than key/value pairs, DocParser assigns it to the annotation's default property. If the annotation class declares no default property, it cannot accept any values and this creation error is thrown with the offending values JSON-encoded.","triggerScenarios":"Using single-value syntax like @Annotation(\"something\") or @Annotation({1,2,3}) on an annotation class whose metadata has an empty default_property (no 'value' property and no named-argument constructor accepting a single value).","commonSituations":"Passing a value to an annotation that is purely a marker (e.g. @Final); copying single-value style from other annotation types; changes to an annotation class that removed its 'value' property.","solutions":["Remove the value and use named attributes instead: @Foo instead of @Foo(\"bar\").","If the annotation should accept a value, add a public $value property (or constructor parameter) to the annotation class so it becomes the default property.","Check the annotation class documentation for the correct usage syntax.","If you meant a different annotation class, correct the annotation name."],"exampleFix":"// before\n/** @Marker(\"debug\") */\n// after\n/** @Marker */","handlingStrategy":"validation","validationCode":"function annotationTakesValue(string $class): bool {\n    try {\n        $v = new ReflectionProperty($class, 'value');\n        return $v->isPublic();\n    } catch (ReflectionException) {\n        return false; // no default property => marker annotation\n    }\n}\n// Only use @Foo(\"x\") syntax if annotationTakesValue(Foo::class)","typeGuard":"function isMarkerAnnotation(string $class): bool {\n    return !annotationTakesValue($class);\n}","tryCatchPattern":"try {\n    $annot = $reader->getPropertyAnnotation($prop, Marker::class);\n} catch (AnnotationException $e) {\n    if (str_contains($e->getMessage(), 'does not accept any values')) {\n        throw new ConfigException('Remove the value from the marker annotation usage', 0, $e);\n    }\n    throw $e;\n}","preventionTips":["Use bare @Marker syntax for annotations without a 'value' property.","Add a public $value property if a single-value form is desired.","Document accepted syntax in each custom annotation class.","CI-parse all docblocks to catch value-on-marker mistakes."],"tags":["php","doctrine-annotations","default-property","annotation-parsing"],"backgroundTag":"invalid-argument-value","analyzedSha":"17815fb6b2f4c3c701ba2abdf2c6c97b219fb2e4","analyzedAt":"2026-09-15T20:30:41.547Z","contentChangedAt":"2026-09-15T20:30:41.547Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}