Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

seb-jean
Copy link
Contributor

@seb-jean seb-jean commented Apr 24, 2025

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.

Copy link

coderabbitai bot commented Apr 24, 2025

Walkthrough

The visibility of the TYPE_NAME constant was changed from protected to public across multiple classes in the src/MartinGeorgiev/Doctrine/DBAL/Types/ directory. This adjustment affects a wide range of type classes, including array types and scalar types, as well as anonymous classes in unit tests. The constant values remain unchanged, and no changes were made to logic, control flow, or error handling.

Changes

File(s) Change Summary
Base Type Class
src/MartinGeorgiev/Doctrine/DBAL/Types/BaseType.php
Changed TYPE_NAME constant visibility from protected to public in BaseType.
Array Type Classes
src/MartinGeorgiev/Doctrine/DBAL/Types/BigIntArray.php, BooleanArray.php, CidrArray.php, InetArray.php, IntegerArray.php, JsonbArray.php, MacaddrArray.php, PointArray.php, RealArray.php, SmallIntArray.php, TextArray.php
Changed TYPE_NAME constant visibility from protected to public.
Scalar and Other Type Classes
src/MartinGeorgiev/Doctrine/DBAL/Types/Cidr.php, Inet.php, Jsonb.php, Macaddr.php, Point.php, DoublePrecisionArray.php
Changed TYPE_NAME constant visibility from protected to public.
Tests with Anonymous Classes
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseNetworkTypeArrayTest.php, BaseTypeTest.php
Changed TYPE_NAME constant visibility from protected to public in anonymous classes used in tests.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

A hop and a skip through the code today,
Constants emerged to the light of day.
From protected to public, they now can be seen,
In arrays and types, and all in between.
The rabbit applauds with a coding cheer,
"Your type names are public, so crystal clear!"
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9fc2025 and 84edac7.

📒 Files selected for processing (3)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BaseType.php (1 hunks)
  • tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseNetworkTypeArrayTest.php (1 hunks)
  • tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseTypeTest.php (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseNetworkTypeArrayTest.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BaseType.php
  • tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseTypeTest.php
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@seb-jean seb-jean force-pushed the feat/type-name-visibility branch from 567ba62 to fc7b44f Compare April 24, 2025 06:56
@coveralls
Copy link

coveralls commented Apr 24, 2025

Coverage Status

coverage: 93.789%. remained the same
when pulling de52f4c on seb-jean:feat/type-name-visibility
into 8dbbf8c on martin-georgiev:main.

@martin-georgiev
Copy link
Owner

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.

@seb-jean
Copy link
Contributor Author

seb-jean commented Apr 24, 2025

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.

@martin-georgiev martin-georgiev changed the title feat: change TYPE_NAME visibility feat!: change TYPE_NAME visibility May 13, 2025
@martin-georgiev
Copy link
Owner

martin-georgiev commented May 13, 2025

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.

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