Skip to content

Fix getID method to handle null values and always return a string#77

Open
Axiome974 wants to merge 1 commit into
zammad:masterfrom
Axiome974:patch-1
Open

Fix getID method to handle null values and always return a string#77
Axiome974 wants to merge 1 commit into
zammad:masterfrom
Axiome974:patch-1

Conversation

@Axiome974
Copy link
Copy Markdown

getID() should always return a string, but in some cases it returns an integer.

getID() should always return a string, but in some cases it returns an integer.
@derpixler
Copy link
Copy Markdown

@Axiome974 Thanks for the PR! The fix looks good -- the explicit (string) cast and null check solve the type inconsistency from json_decode() where IDs come back as integers.

Two small suggestions:

  1. Please update the docblock to @return string|null since the method now explicitly returns null for unsaved objects.
  2. Consider adding a simple test for getID() (e.g., returns null for an unsaved object, returns a string after fetch).

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