Skip to content

refactor: convert error codes, breakpoint types and setting keys to enums - #14

Merged
lisachenko merged 1 commit into
mainfrom
claude/zdebug-php-enums-48mgvj
Aug 8, 2026
Merged

refactor: convert error codes, breakpoint types and setting keys to enums#14
lisachenko merged 1 commit into
mainfrom
claude/zdebug-php-enums-48mgvj

Conversation

@lisachenko

Copy link
Copy Markdown
Owner

Converts three groups of class constants to native PHP enums, as requested.

Changes

ErrorCode (int-backed enum)

The DBGp error-code constants (PARSE_ERROR, UNIMPLEMENTED, BREAKPOINT_INVALID, …) become cases of an int-backed enum (ErrorCode::ParseError, ErrorCode::Unimplemented, …), keeping the range grouping comments from the spec. ResponseBuilder::error() and CommandDispatcher::error() now take ErrorCode instead of a bare int and render ->value on the wire, so an arbitrary integer can no longer be sent as an error code.

BreakpointType (new string-backed enum)

The Breakpoint::TYPE_LINE / TYPE_CONDITION / TYPE_EXCEPTION string constants move to a dedicated BreakpointType enum (Line, Conditional, Exception). Breakpoint::$type is now typed as the enum, and breakpoint_set validates the -t argument with BreakpointType::tryFrom() instead of a hand-written three-way comparison. The DBGp XML output still carries the same string values via ->value. The HIT_* hit-condition constants are untouched, as they were not in scope.

Setting (new string-backed enum)

The Settings key constants (CLIENT_HOST, CLIENT_PORT, IDE_KEY, …) move to a Setting enum whose backing values are the documented public config-array keys, so the public Debugger::attach(['client_port' => …]) API is unchanged. The Settings bag's methods (has/get/set/string/int/stringOrNull/stringList) now accept Setting while keeping string-keyed storage internally, and Debugger::mapArrayKeys() derives its allowlist from Setting::cases() instead of a hand-maintained list.

Verification

  • composer test — 137 tests, 656 assertions, all passing
  • composer phpstan — level max, no errors
  • composer cs:check — clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01DJrpKBnxGuETRv7UFzUpcF


Generated by Claude Code

…nums

Replace three groups of class constants with native PHP enums:

- ErrorCode becomes an int-backed enum of the DBGp error codes;
  ResponseBuilder::error() and CommandDispatcher::error() now accept it
  directly and render ->value on the wire.
- The Breakpoint TYPE_* string constants move to a new string-backed
  BreakpointType enum; Breakpoint::$type is now typed as the enum and
  breakpoint_set validates the -t argument with tryFrom().
- The Settings key constants move to a new string-backed Setting enum;
  the Settings bag accepts Setting keys while keeping its string-keyed
  storage, so the documented config array keys stay unchanged, and
  Debugger derives the allowed keys from Setting::cases().

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DJrpKBnxGuETRv7UFzUpcF
@lisachenko
lisachenko marked this pull request as ready for review August 8, 2026 07:03
@lisachenko
lisachenko merged commit 4bcba27 into main Aug 8, 2026
5 checks passed
@lisachenko
lisachenko deleted the claude/zdebug-php-enums-48mgvj branch August 8, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants