Skip to content

fix: generate valid property names for any field name and json_name - #49

Merged
kafkiansky merged 1 commit into
0.6.xfrom
fix/invalid-property-names
Nov 22, 2026
Merged

kafkiansky merged 1 commit into
0.6.xfrom
fix/invalid-property-names

Conversation

@kafkiansky

Copy link
Copy Markdown
Contributor

A property was named after the json_name of its field, which may be any string: json_name = "my-field" failed with a Nette stack trace, and a field or oneof named this produced $this, which PHP rejects as a parameter.

json_name still names the property while it is a valid PHP variable name. Otherwise the name is derived from the field name in camelCase, and this becomes this_. Classes of oneof variants are built from the same name, so an invalid json_name no longer gives an invalid class name.

Two fields, or a field and a oneof, that end up with the same property used to silently drop one of them; generation now fails with CodeCannotBeGenerated naming both.

A property was named after the json_name of its field, which may be any
string: `json_name = "my-field"` failed with a Nette stack trace, and a
field or oneof named `this` produced `$this`, which PHP rejects as a
parameter.

json_name still names the property while it is a valid PHP variable
name. Otherwise the name is derived from the field name in camelCase,
and `this` becomes `this_`. Classes of oneof variants are built from the
same name, so an invalid json_name no longer gives an invalid class name.

Two fields, or a field and a oneof, that end up with the same property
used to silently drop one of them; generation now fails with
CodeCannotBeGenerated naming both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@kafkiansky kafkiansky self-assigned this Nov 22, 2026
@kafkiansky kafkiansky added the enhancement New feature or request label Nov 22, 2026
@kafkiansky
kafkiansky merged commit c297e3f into 0.6.x Nov 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant