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 3 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
src/MartinGeorgiev/Doctrine/DBAL/Types/BaseType.php Changed TYPE_NAME constant visibility from protected to public in BaseType.
Multiple array type classes:
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.
Multiple scalar type classes:
Cidr.php, Inet.php, Jsonb.php, Macaddr.php, Point.php, DoublePrecisionArray.php
Changed TYPE_NAME constant visibility from protected to public.
Tests:
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.

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!"
🐇✨


📜 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 567ba62 and 9fc2025.

📒 Files selected for processing (20)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BaseType.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BigIntArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Cidr.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/CidrArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/DoublePrecisionArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Inet.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/InetArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/IntegerArray.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/Macaddr.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/MacaddrArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Point.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/PointArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/RealArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/SmallIntArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.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 (3)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BigIntArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/MacaddrArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/InetArray.php
🚧 Files skipped from review as they are similar to previous changes (15)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Cidr.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Macaddr.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Point.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/DoublePrecisionArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/CidrArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/RealArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/SmallIntArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/IntegerArray.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Inet.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BaseType.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/PointArray.php
🧰 Additional context used
🧠 Learnings (1)
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseTypeTest.php (1)
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#309
File: tests/MartinGeorgiev/Doctrine/DBAL/Types/BaseTypeTest.php:0-0
Timestamp: 2025-03-26T23:51:33.709Z
Learning: The requiresSQLCommentHint() method is intentionally kept in tests to support backwards compatibility with older Doctrine DBAL versions, even though it's deprecated in newer versions and triggers static analysis warnings. The method isn't used in production code.
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 1.2
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: sloth
🔇 Additional comments (6)
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseNetworkTypeArrayTest.php (1)

26-26: Visibility change aligns with PR objective.

The visibility change from protected to public for the TYPE_NAME constant in this anonymous test class properly reflects the change implemented in the production code. This change enables direct reference to type constants in Doctrine annotations, as stated in the PR objectives.

tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/BaseTypeTest.php (5)

30-30: Visibility change matches PR objective.

The change from protected to public for TYPE_NAME in this test case correctly aligns with the feature change in the corresponding production code.


45-45: Visibility change matches PR objective.

The change from protected to public for TYPE_NAME in this test case ensures consistency with the actual implementation.


60-60: Visibility change matches PR objective.

The change from protected to public for TYPE_NAME properly reflects the implementation change and ensures the test functions correctly with the new visibility.


72-72: Visibility change matches PR objective.

The change from protected to public for TYPE_NAME in this test case ensures that tests are aligned with the actual implementation.


91-91: Visibility change matches PR objective.

The change from protected to public for TYPE_NAME in this test case is consistent with the other changes and aligns with the feature implementation.

Note: As mentioned in the learnings, the requiresSQLCommentHint() method is intentionally kept for backward compatibility with older Doctrine DBAL versions despite being deprecated in newer versions.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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