-
-
Notifications
You must be signed in to change notification settings - Fork 55
feat!: change TYPE_NAME visibility #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughVisibility of the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Files/areas to spot-check:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
567ba62 to
fc7b44f
Compare
|
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php (1)
24-24: Follow the maintainer's proposed alternative approach.The visibility change is technically correct, but the maintainer has explicitly indicated this approach conflicts with the intended API design. The
TYPE_NAMEconstant was intentionallyprotectedas an implementation detail.As discussed in the PR comments, consider implementing the maintainer's suggested alternative: introduce a new
Typesenum or class (similar to Doctrine DBAL's pattern) that defines public type-name constants. The existingTYPE_NAMEconstants in each class can then reference those public constants internally without changing their visibility. This approach:
- Provides the public API you need for Doctrine attributes
- Maintains the separation between public API and implementation details
- Follows established Doctrine DBAL patterns
- Avoids expanding the API surface of each type class
src/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php (1)
22-22: Consider the alternative approach proposed by the maintainer.While the visibility change is syntactically correct, expanding the public API surface for TYPE_NAME has long-term implications. Once public, this constant becomes part of the API contract and any future modifications would be breaking changes.
The maintainer proposed an alternative solution: introduce a dedicated Types class/enum with public type-name constants (mirroring Doctrine DBAL's pattern), then refactor existing protected TYPE_NAME constants to reference those new public constants. This approach would:
- Provide the type-safe entity attribute usage you're seeking
- Avoid changing existing constant visibility
- Create an explicit, intentional public API for type names
- Maintain clearer separation between internal implementation and public interface
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php(1 hunks)src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php(1 hunks)src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php(1 hunks)src/MartinGeorgiev/Doctrine/DBAL/Types/Point.php(1 hunks)src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what TYPE_NAME constants contain and getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the point[] array type should be documented as "point[]" not "_point" in the AVAILABLE-TYPES.md table, to be consistent with all other array types like text[], jsonb[], inet[], etc.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
📚 Learning: 2025-08-19T13:07:15.184Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what TYPE_NAME constants contain and getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Applied to files:
src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/Point.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php
📚 Learning: 2025-08-19T13:07:15.184Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Applied to files:
src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php
📚 Learning: 2025-03-26T02:46:12.804Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 0
File: :0-0
Timestamp: 2025-03-26T02:46:12.804Z
Learning: The PR "preserve the type of floats and integers when transforming back and forth between PostgreSQL and PHP" improves type handling by ensuring that integers remain integers, floats remain floats, numeric strings stay as strings, and booleans are properly converted through the transformation process.
Applied to files:
src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php
📚 Learning: 2025-08-19T13:07:15.184Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the point[] array type should be documented as "point[]" not "_point" in the AVAILABLE-TYPES.md table, to be consistent with all other array types like text[], jsonb[], inet[], etc.
Applied to files:
src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/Point.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php
📚 Learning: 2025-09-06T22:15:32.757Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 443
File: tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php:169-172
Timestamp: 2025-09-06T22:15:32.757Z
Learning: In martin-georgiev/postgresql-for-doctrine, TextArray users should expect the database to normalize data to strings only. The design assumes that intended PHP data for TextArray is always strings, not other data types, which is a reasonable tradeoff that aligns with PostgreSQL text[] type semantics.
Applied to files:
src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php
📚 Learning: 2025-08-24T16:52:32.488Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 0
File: :0-0
Timestamp: 2025-08-24T16:52:32.488Z
Learning: This repository uses BaseType extension pattern for custom Doctrine DBAL types with PostgreSQL platform assertions, comprehensive unit and integration testing with data providers, and dedicated exception classes for type conversion errors.
Applied to files:
src/MartinGeorgiev/Doctrine/DBAL/Types/Point.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
- GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
- GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 3.0
- GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
- GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
- GitHub Check: Code Quality
- GitHub Check: wait-for-tests-worflows-before-upload
🔇 Additional comments (2)
src/MartinGeorgiev/Doctrine/DBAL/Types/Point.php (1)
23-23: Consider the alternative approach suggested by the maintainer.While the implementation is clean, the PR comments indicate the maintainer objects to changing TYPE_NAME visibility, as it was intentionally protected. The maintainer proposed an alternative: introduce a new Types enum/class (mirroring Doctrine DBAL's pattern) with public type-name constants, then refactor existing TYPE_NAME constants to reference those new public constants.
This approach would achieve the goal of providing public constants for use in entity attributes without altering the existing protected API contract.
Please confirm whether you'd like to proceed with the maintainer's suggested alternative before continuing with this visibility change approach.
src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php (1)
22-22: The review comment is unsupported by verifiable evidence and should be disregarded.The TYPE_NAME visibility change from
protectedtopublicwas already committed in commit fc7b44f and is part of the current branch history. The review comment's claims about maintainer objections to this approach and a proposed Types enum/class alternative cannot be verified in the codebase or accessible PR context. No such alternative exists, and no evidence of objections from the maintainer is available. The change has already been made and integrated.Likely an incorrect or invalid review comment.
Currently, I need to do this in my Doctrine entity:
It would be interesting to do this:
Summary by CodeRabbit