[MODEL] Incorrect claim about PHP readonly classes during autonomous code generation

Resolved 💬 5 comments Opened Jan 31, 2026 by koekaverna Closed Mar 1, 2026

Preflight Checklist

  • [x] I have searched existing issues for similar behavior reports
  • [x] This report does NOT contain sensitive information (API keys, passwords, etc.)

Type of Behavior Issue

Other unexpected behavior

What You Asked Claude to Do

Implement a class (Symfony EventListener decorator). Standard code generation task.

What Claude Actually Did

  1. Created the class successfully
  2. Ran a linting tool (Rector) which suggested making the class readonly
  3. Autonomously decided to skip this valid suggestion
  4. Stated as fact: "a readonly class cannot have constants in PHP"
  5. Left the class as non-readonly

Expected Behavior

Claude should have either:

  1. Applied the readonly modifier (correct action)
  2. Or said "I'm not sure about this PHP feature, let me check" (acceptable)

Instead, Claude confidently stated an incorrect fact about a core language feature.

Files Affected

src/EventListener/Payment/PaymentErrorListenerDecorator.php

Permission Mode

Accept Edits was ON (auto-accepting changes)

Can You Reproduce This?

Haven't tried to reproduce

Claude Model

Opus

Relevant Conversation

Claude: "Rector хочет применить ReadOnlyClassRector — сделать класс readonly. 
Но класс имеет private const, а readonly class не может иметь констант в PHP. 
Поэтому Rector изменение некорректно — класс останется как есть."

Me: "Нет, это неправда. Readonly class в PHP может иметь константы."

Claude: "Вы правы, я ошибся. readonly class может иметь константы — 
ограничение касается только свойств."

Impact

Medium - Extra work to undo changes

Claude Code Version

2.1.27 (Claude Code)

Platform

Anthropic API

Additional Context

The false claim: "readonly class cannot have constants in PHP"

The truth: PHP readonly classes fully support constants (public, protected, private). The restrictions are only: all properties become readonly, no static properties, no dynamic properties.

This is a basic PHP 8.2 language feature. Related issue with similar PHP knowledge problem: #15805

Question for Anthropic: Are there safeguards against adversarial data poisoning via "Allow training on my data"? Could false facts like this originate from intentionally submitted incorrect feedback?

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗