feat!: change TYPE_NAME visibility
Currently, I need to do this in my Doctrine entity:
#[ORM\Column(type: 'point')]
public PointValueObject $point;
It would be interesting to do this:
#[ORM\Column(type: Point::TYPE_NAME)]
public PointValueObject $point;
Summary by CodeRabbit
- Refactor
- Made type name constants publicly accessible across all supported types, improving visibility for end-users and integrations.
Walkthrough
Visibility of the TYPE_NAME constant was changed from protected to public across many DBAL type classes and anonymous test classes; constant values and code logic remain unchanged.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Base Typesrc/MartinGeorgiev/Doctrine/DBAL/Types/BaseType.php |
TYPE_NAME constant visibility changed from protected → public. |
Array Typessrc/MartinGeorgiev/Doctrine/DBAL/Types/*Array.php (e.g. BigIntArray.php, BooleanArray.php, CidrArray.php, InetArray.php, IntegerArray.php, JsonbArray.php, MacaddrArray.php, PointArray.php, RealArray.php, SmallIntArray.php, TextArray.php, DoublePrecisionArray.php) |
TYPE_NAME constant visibility changed from protected → public. |
Scalar / Other Typessrc/MartinGeorgiev/Doctrine/DBAL/Types/Cidr.php, Inet.php, Jsonb.php, Macaddr.php, Point.php |
TYPE_NAME constant visibility changed from protected → public. |
Unit Tests (anonymous classes)tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseNetworkTypeArrayTest.php, tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseTypeTest.php |
TYPE_NAME constant visibility in anonymous test subclasses changed from protected → public. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Files/areas to spot-check:
BaseType.php(ensure public constant use doesn't break API expectations).- Representative concrete type files (e.g.,
Jsonb.php,IntegerArray.php) to verify no accidental edits beyond visibility. - Tests that define anonymous classes to confirm assertions still valid.
Possibly related PRs
- martin-georgiev/postgresql-for-doctrine#309 — Related tests and TYPE_NAME visibility adjustments referenced/affected by this change.
- martin-georgiev/postgresql-for-doctrine#307 — Overlaps with visibility changes for specific array types (e.g.,
DoublePrecisionArray,RealArray). - martin-georgiev/postgresql-for-doctrine#289 — Previous changes touching
TYPE_NAMEdeclarations across types.
Poem
I hopped through constants, gentle and quick,
From hidden to public, a tiny trick.
TYPE_NAME now waves in broad daylight,
Arrays and points gleam tidy and bright.
A rabbit’s cheer for one small tweak — hop, click! 🐇✨
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'feat!: change TYPE_NAME visibility' clearly and concisely describes the primary change across all affected files—making the TYPE_NAME constant public instead of protected. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
coverage: 93.789%. remained the same when pulling de52f4c29f910cc9fade7e2cf079ec412b2ac8f4 on seb-jean:feat/type-name-visibility into 8dbbf8c71b801bd624829e04504919d730ff4a57 on martin-georgiev:main.
Currently, I disagree with this change - due to a single use case, the change unnecessarily alters the visibility of a constant that was not intended to be public.
Currently, I disagree with this change - due to a single use case, the change unnecessarily alters the visibility of a constant that was not intended to be public.
This is something that is done in Doctrine DBAL: https://github.com/doctrine/dbal/blob/4.2.x/src/Types/Types.php#L12-L36
This allows you to avoid making a mistake in the name of the data type.
This is a potentially breaking change. It won't get merged until the next major version bump, which I don't expect to happen soon. A better solution would be to introduce a new Types enum/class exactly in the same way as it is done for Doctrine, and refactor the TYPE_NAME constants so they reuse the new constants defined in that Types.
@seb-jean , can you please implement the suggestions from https://github.com/martin-georgiev/postgresql-for-doctrine/pull/362#issuecomment-2876268812?