Skip to content

fix: keep extension names made of digits - #72

Open
EmiRZx wants to merge 1 commit into
cloudevents:mainfrom
EmiRZx:fix-numeric-extension-names
Open

EmiRZx wants to merge 1 commit into
cloudevents:mainfrom
EmiRZx:fix-numeric-extension-names

Conversation

@EmiRZx

@EmiRZx EmiRZx commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

fixes #71. keys are cast back to strings before setExtension() and in the fromArray() switch. attributes are now combined with array_replace() instead of array_merge(), which keeps int keys. the name regex now ends with \z. the docblocks for the constructor and withExtensions() accept int keys. the five new tests fail on main and pass here. tests pass on PHP 7.4 and 8.4. phpcs and psalm are clean. it merges cleanly with #68.

PHP turns an array key such as "123" into an int. The constructor,
withExtensions() and createFromInterface() then failed with a
TypeError. array_merge() renamed the extension to "0" when serializing.
A ce-123 header was also read back as "0". On PHP 7 a key 0 matched the
specversion case and was dropped. Keys are now cast back to strings and
merged with array_replace().

The name check also no longer accepts a trailing newline.

Signed-off-by: emir <52245396+EmiRZx@users.noreply.github.com>
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.

Extension names made of digits fail or get renamed

1 participant