Skip to content

fix(model): hydrate nullable fields via BaseModel helpers - #289

Merged
andrii-bodnar merged 3 commits into
masterfrom
code-refactoring
Oct 2, 2026
Merged

andrii-bodnar merged 3 commits into
masterfrom
code-refactoring

Conversation

@bhdnb

@bhdnb bhdnb commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Hydrate all nullable model fields through BaseModel::nullable*() instead of a mix of uncast assignments, truthy ternaries and plain casts.
  • Add tests for the helpers and for the two behavior changes below.
  • Remove 656 method docblocks in Model/ that only repeated the native signature. Docblocks that add information (element types, descriptions, @deprecated) are kept.

Behavior changes

Getter signatures are unchanged; returned values differ in two cases:

  • Falsy API values are kept instead of becoming null, e.g. TaskComment::getTimeSpent() returns 0, File::getExcludedTargetLanguages() returns [].
  • Fields the API marks nullable or optional return null instead of '' / 0 when missing: DistributionRelease, Language::getDialectOf(), Project::getInContextPseudoLanguageId(), ProgressLanguage::getEtag(), Task::getHash(), TranslationMemorySegmentRecord timestamps.

Field nullability was checked against the Crowdin and Enterprise API specs.

@bhdnb
bhdnb requested a review from andrii-bodnar October 1, 2026 14:42
@bhdnb bhdnb self-assigned this Oct 1, 2026
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.18%. Comparing base (3ffdaa5) to head (8d1d565).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #289      +/-   ##
============================================
- Coverage     95.19%   95.18%   -0.00%     
+ Complexity     2540     2510      -30     
============================================
  Files           217      217              
  Lines          6959     6925      -34     
============================================
- Hits           6624     6591      -33     
+ Misses          335      334       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The broad public hydration changes across 74 files warrant final human validation against the API specifications.

Review effort: Balanced
Findings: None

What changed in this PR

Standardizes nullable model hydration while preserving valid falsy API values and removes redundant model method docblocks.

Changes:

  • Uses BaseModel nullable helpers across affected models.
  • Adds helper and regression tests.
  • Removes PHPDoc that duplicates native signatures.
File Description
tests/​CrowdinApiClient/​Model/​TaskCommentTest.php Tests zero and null time values.
tests/​CrowdinApiClient/​Model/​DistributionReleaseTest.php Tests absent nullable fields.
tests/​CrowdinApiClient/​Model/​BaseModelTest.php Tests all nullable helpers.
src/​CrowdinApiClient/​Model/​WordAlignment.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​Webhook.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​Vote.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​UserReportSettingsTemplate.php Standardizes nullable timestamp hydration.
src/​CrowdinApiClient/​Model/​User.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​TranslationProjectDirectory.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​TranslationMemorySegmentRecord.php Preserves nullable timestamps.
src/​CrowdinApiClient/​Model/​TranslationMemorySegment.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​TranslationMemoryImport.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​TranslationMemoryExport.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​TranslationMemoryConcordance.php Casts nullable strings consistently.
src/​CrowdinApiClient/​Model/​TranslationMemory.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​Term.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​TaskSettingsTemplate.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​TaskForUpdate.php Standardizes nullable date hydration.
src/​CrowdinApiClient/​Model/​TaskComment.php Preserves zero time spent.
src/​CrowdinApiClient/​Model/​Task.php Standardizes optional task fields.
src/​CrowdinApiClient/​Model/​Tag.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​StyleGuide.php Casts optional fields consistently.
src/​CrowdinApiClient/​Model/​StringUpload.php Standardizes nullable job timestamps.
src/​CrowdinApiClient/​Model/​StringTranslationApproval.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​StringTranslation.php Standardizes nullable identifiers.
src/​CrowdinApiClient/​Model/​StringsExporterSetting.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​StringCorrection.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​StringComment.php Normalizes PHPDoc and formatting.
src/​CrowdinApiClient/​Model/​Storage.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​SourceString.php Preserves nullable numeric identifiers.
src/​CrowdinApiClient/​Model/​SecurityLog.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​Screenshot.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​ReportSettingsTemplate.php Standardizes nullable update timestamp.
src/​CrowdinApiClient/​Model/​Report.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​QaCheck.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​Project.php Preserves nullable pseudo-language ID.
src/​CrowdinApiClient/​Model/​ProgressLanguage.php Preserves nullable ETag.
src/​CrowdinApiClient/​Model/​ProgressFile.php Standardizes nullable ETag hydration.
src/​CrowdinApiClient/​Model/​Progress.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​OrganizationWebhook.php Cleans PHPDoc and formatting.
src/​CrowdinApiClient/​Model/​MachineTranslationEngine.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​MachineTranslation.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​LanguageTranslation.php Preserves falsy optional values.
src/​CrowdinApiClient/​Model/​Language.php Preserves nullable dialect relation.
src/​CrowdinApiClient/​Model/​Issue.php Cleans PHPDoc and formatting.
src/​CrowdinApiClient/​Model/​HourlyUserReportSettingsTemplate.php Standardizes nullable update timestamp.
src/​CrowdinApiClient/​Model/​Group.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​GlossaryImport.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​GlossaryExport.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​FileRevision.php Preserves zero restore revision.
src/​CrowdinApiClient/​Model/​File.php Preserves empty language exclusions.
src/​CrowdinApiClient/​Model/​Enterprise/​Vendor.php Cleans PHPDoc and formatting.
src/​CrowdinApiClient/​Model/​Enterprise/​User.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​Enterprise/​Group.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​DownloadFileTranslation.php Standardizes nullable ETag hydration.
src/​CrowdinApiClient/​Model/​DownloadFilePreview.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​DownloadFile.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​DistributionRelease.php Preserves absent fields as null.
src/​CrowdinApiClient/​Model/​Directory.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​DeleteJob.php Casts nullable job fields consistently.
src/​CrowdinApiClient/​Model/​BranchMerge.php Standardizes nullable job timestamps.
src/​CrowdinApiClient/​Model/​BranchClone.php Standardizes nullable job timestamps.
src/​CrowdinApiClient/​Model/​Branch.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​ApplicationInstallation.php Casts optional installation fields.
src/​CrowdinApiClient/​Model/​ApplicationConsent.php Casts optional consent fields.
src/​CrowdinApiClient/​Model/​Alignment.php Removes redundant PHPDoc.
src/​CrowdinApiClient/​Model/​AiSettings.php Casts nullable prompt IDs.
src/​CrowdinApiClient/​Model/​AiRequestLog.php Casts nullable log metadata.
src/​CrowdinApiClient/​Model/​AiReport.php Standardizes nullable timestamps.
src/​CrowdinApiClient/​Model/​AiProviderModel.php Casts optional provider metadata.
src/​CrowdinApiClient/​Model/​AiProvider.php Casts nullable credentials.
src/​CrowdinApiClient/​Model/​AiPromptCompletion.php Standardizes nullable timestamps.
src/​CrowdinApiClient/​Model/​AiPrompt.php Casts optional prompt metadata.
src/​CrowdinApiClient/​Model/​AiFileTranslation.php Standardizes nullable timestamps.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@andrii-bodnar
andrii-bodnar merged commit 325d96c into master Oct 2, 2026
14 checks passed
@andrii-bodnar
andrii-bodnar deleted the code-refactoring branch October 2, 2026 06:29
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.

3 participants