Skip to content

fix: update database property type to nullable and handle defaults in…#166

Merged
abnegate merged 2 commits intomainfrom
backward-commpat-database
Mar 19, 2026
Merged

fix: update database property type to nullable and handle defaults in…#166
abnegate merged 2 commits intomainfrom
backward-commpat-database

Conversation

@ArnabChatterjee20k
Copy link
Contributor

… fromArray method

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 19, 2026

Greptile Summary

This PR makes the $database property on the Database resource nullable and guards the fromArray() factory against a missing database key by defaulting to null. The intent is correct and aligns with real-world data where the field may be absent, but two minor issues were left behind:

  • The getDatabase() return type was changed to mixed rather than the more precise ?string, which unnecessarily degrades type safety for all callers.
  • The @param array-shape docblock for fromArray() still declares database: string as a required, non-nullable field, making it inaccurate after this change.

Confidence Score: 4/5

  • Safe to merge — the behavioural fix is correct and callers already handle nullable strings (e.g. Reader/Database::getDatabase(?string)).
  • The core fix (nullable property + null default in fromArray) is sound and the existing callers of getDatabase()->getDatabase() already accept ?string. The only issues are a return type that is more permissive than needed (mixed vs ?string) and a stale docblock — neither affects runtime behaviour.
  • No files require special attention beyond the two style suggestions in src/Migration/Resources/Database/Database.php.

Important Files Changed

Filename Overview
src/Migration/Resources/Database/Database.php Makes $database nullable and adds a null default in fromArray() — functionally correct, but getDatabase() return type was unnecessarily broadened to mixed instead of the precise ?string, and the PHPDoc shape for fromArray() was not updated to reflect the optional/nullable database key.

Comments Outside Diff (1)

  1. src/Migration/Resources/Database/Database.php, line 35-43 (link)

    P2 PHPDoc not updated to reflect nullable database key

    The @param array shape still declares database: string, but the key is now effectively optional and can be absent (defaulting to null). This makes the docblock inaccurate and may mislead callers and static analysis tools.

Last reviewed commit: "fix: update database..."

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@abnegate abnegate merged commit 8633523 into main Mar 19, 2026
3 checks passed
@abnegate abnegate deleted the backward-commpat-database branch March 19, 2026 09:18
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