Skip to content

Conversation

@martin-georgiev
Copy link
Owner

@martin-georgiev martin-georgiev commented Apr 21, 2025

Summary by CodeRabbit

  • Deprecation Notices

    • Marked several functions as deprecated, with notices recommending alternative replacements for future use.
  • Enhancements

    • Improved documentation for regular expression functions, including updated examples and PostgreSQL references.
    • Expanded support for variable argument counts in certain regular expression functions.
  • Bug Fixes

    • Adjusted function argument handling to allow more flexible usage of regular expression flags.
  • Tests

    • Enhanced test coverage for argument validation and updated tests to reflect changes in function signatures and deprecations.
    • Suppressed static analysis warnings in test files for deprecated functions.

…precating the legacy limited flagged variations of `FlaggedRegexpLike`, `FlaggedRegexpMatch` and `FlaggedRegexpReplace`
@coderabbitai
Copy link

coderabbitai bot commented Apr 21, 2025

Walkthrough

This update deprecates the FlaggedRegexpLike, FlaggedRegexpMatch, and FlaggedRegexpReplace functions, recommending their respective non-flagged counterparts for future use and noting their removal in version 4.0. The RegexpLike and RegexpMatch functions are refactored to support a variable number of arguments, now extending BaseVariadicFunction and implementing explicit argument count validation and node mapping patterns. Related tests are updated to reflect these changes, including new tests for argument validation and adjustments to expected SQL output. Comments and documentation are enhanced throughout for clarity.

Changes

File(s) Change Summary
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLike.php
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatch.php
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplace.php
Deprecated the FlaggedRegexpLike, FlaggedRegexpMatch, and FlaggedRegexpReplace classes, adding @deprecated annotations and updating documentation.
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLike.php
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatch.php
Refactored to extend BaseVariadicFunction, added support for variable argument counts, improved documentation, and introduced explicit node mapping patterns and argument count validation.
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpReplace.php Clarified PostgreSQL argument overloading in comments and simplified node mapping patterns.
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseRegexpFunction.php Removed the entire abstract class BaseRegexpFunction which provided a fixed-parameter base for regexp functions.
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLikeTest.php
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatchTest.php
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplaceTest.php
Added // @phpstan-ignore-line comments to suppress static analysis warnings on deprecated function mappings.
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLikeTest.php
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatchTest.php
Updated to extend BaseVariadicFunctionTestCase, added fixture creation methods, expanded test cases, and introduced tests for argument count validation.
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpReplaceTest.php Removed test case for "with start position and flags" scenario.
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunctionTestCase.php Changed DQL query in a test method from 'TRUE' to 'SELECT 1' for initialization.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DoctrineDQL
    participant RegexpLike
    participant RegexpMatch

    User->>DoctrineDQL: Build DQL query with regexp_like() or regexp_match()
    DoctrineDQL->>RegexpLike: Parse arguments (2 or 3)
    RegexpLike->>DoctrineDQL: Validate argument count
    DoctrineDQL->>RegexpLike: Map arguments to node pattern
    RegexpLike->>DoctrineDQL: Generate SQL function call
    Note over RegexpLike,RegexpMatch: Same flow applies for RegexpMatch
Loading

Possibly related PRs

Poem

In the fields of code, the flags retire,
As variadic bunnies hop ever higher.
Deprecated paths now softly fade,
While new regex magic is carefully laid.
With arguments counted, and tests in bloom,
Doctrine’s queries leap—no more room for gloom!
🐇✨


📜 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 9aab6f7 and 959a22c.

📒 Files selected for processing (1)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseRegexpFunction.php (0 hunks)
💤 Files with no reviewable changes (1)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseRegexpFunction.php
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 1.2
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.1 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: sloth

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLikeTest.php (1)

19-24: 💡 Verification agent

🧩 Analysis chain

Verify that the test coverage aligns with PostgreSQL documentation.

The test validates basic functionality of regexp_like with a pattern and flags, but could benefit from more comprehensive test cases that demonstrate the various flag options.


🏁 Script executed:

#!/bin/bash
# Check if the test covers examples from PostgreSQL documentation
echo "Checking for comprehensive test coverage based on PostgreSQL examples..."

# Look for test cases for the non-deprecated RegexpLike
rg -n "regexp_like" tests/

Length of output: 1459


Enhance test coverage for all RegexpLike flag options

While the existing tests in RegexpLikeTest.php and FlaggedRegexpLikeTest.php verify basic matching and the ignore‑case ('i') flag, PostgreSQL’s regexp_like supports additional flags and flag combinations. Please add tests to cover:

  • Single‑letter flags:
    • 'c' (case‑sensitive)
    • 'm' (multi‑line mode)
    • 'n' (new‑line sensitive)
    • 's' (dot‑all mode)
    • 'x' (extended mode)
  • Combined flags (e.g., 'im', 'msx')
  • Edge cases where flags have no effect or conflict

Locations to update:

  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLikeTest.php
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLikeTest.php

This will ensure alignment with PostgreSQL’s documented behavior and catch regressions across all flag scenarios.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9959476 and ada5563.

📒 Files selected for processing (11)
  • docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLike.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatch.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplace.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLike.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatch.php (1 hunks)
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLikeTest.php (1 hunks)
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatchTest.php (1 hunks)
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplaceTest.php (1 hunks)
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLikeTest.php (2 hunks)
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatchTest.php (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/**/*.php`: Use the PostgreSQL official documentation to verify that tests include comprehensive use cases and example SQL que...

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/**/*.php: Use the PostgreSQL official documentation to verify that tests include comprehensive use cases and example SQL queries for the tested SQL functions and operators.

  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLikeTest.php
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplaceTest.php
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatchTest.php
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLikeTest.php
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatchTest.php
🧠 Learnings (1)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLikeTest.php (2)
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#318
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/XmlAggTest.php:1-9
Timestamp: 2025-03-29T03:31:17.114Z
Learning: Tests in the `Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions` namespace extend a custom `TestCase` class from the same namespace (`Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TestCase`), rather than PHPUnit's TestCase, and therefore don't need an explicit import.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#318
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/XmlAggTest.php:1-9
Timestamp: 2025-03-29T03:31:17.114Z
Learning: Tests in the `Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions` namespace extend a custom `TestCase` class from the same namespace (`Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TestCase`), not PHPUnit's TestCase, and therefore don't need an explicit import statement.
🧬 Code Graph Analysis (4)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLikeTest.php (1)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLike.php (1)
  • FlaggedRegexpLike (17-26)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatchTest.php (1)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatch.php (1)
  • FlaggedRegexpMatch (17-26)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatchTest.php (5)
fixtures/MartinGeorgiev/Doctrine/Entity/ContainsTexts.php (1)
  • ORM (10-18)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • BaseVariadicFunction (20-135)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Exception/InvalidArgumentForVariadicFunctionException.php (1)
  • InvalidArgumentForVariadicFunctionException (7-56)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatch.php (1)
  • RegexpMatch (19-45)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunctionTestCase.php (1)
  • BaseVariadicFunctionTestCase (14-42)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLike.php (3)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (5)
  • BaseVariadicFunction (20-135)
  • getNodeMappingPattern (32-32)
  • getFunctionName (27-27)
  • getMinArgumentCount (34-34)
  • getMaxArgumentCount (36-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatch.php (4)
  • getNodeMappingPattern (21-29)
  • getFunctionName (31-34)
  • getMinArgumentCount (36-39)
  • getMaxArgumentCount (41-44)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseRegexpFunction.php (1)
  • getFunctionName (9-9)
🪛 markdownlint-cli2 (0.17.2)
docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md

85-85: Table pipe style
Expected: leading_only; Actual: leading_and_trailing; Unexpected trailing pipe

(MD055, table-pipe-style)


86-86: Table pipe style
Expected: leading_only; Actual: leading_and_trailing; Unexpected trailing pipe

(MD055, table-pipe-style)


87-87: Table pipe style
Expected: leading_only; Actual: leading_and_trailing; Unexpected trailing pipe

(MD055, table-pipe-style)

🔇 Additional comments (28)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatch.php (1)

7-10: Appropriate deprecation notice with clear migration path.

The deprecation notice clearly indicates when this function will be removed and what alternative to use instead. This gives users time to migrate to the recommended RegexpMatch class before v4.0.

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatchTest.php (2)

15-15: Good use of static analysis suppression for deprecated code.

Adding the @phpstan-ignore-line comment is appropriate for suppressing static analysis warnings on code that's intentionally using deprecated functionality. This allows the tests to continue validating the deprecated class during its deprecation period.


19-24:

✅ Verification successful

Verify that the test coverage aligns with PostgreSQL documentation.

The test validates the basic functionality of regexp_match with a pattern and flags, but could benefit from more comprehensive test cases.


🏁 Script executed:

#!/bin/bash
# Check if the test covers examples from PostgreSQL documentation
echo "Checking for comprehensive test coverage based on PostgreSQL examples..."

# Look for additional test cases in other files
rg -n "regexp_match" tests/

Length of output: 1471


Test Coverage Is Already Comprehensive

The existing RegexpMatchTest covers:

  • Basic pattern matching
  • Matching with flags
  • Matching with a start position
  • Matching with both start position and flags
  • Argument validation and exception cases

No additional test cases are required to align with the PostgreSQL documentation.

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLikeTest.php (1)

15-15: Good use of static analysis suppression for deprecated code.

Adding the @phpstan-ignore-line comment is appropriate for suppressing static analysis warnings on code that's intentionally using deprecated functionality. This maintains test coverage during the deprecation period.

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplaceTest.php (2)

15-15: Good use of static analysis suppression for deprecated code.

Adding the @phpstan-ignore-line comment is appropriate for suppressing static analysis warnings on code that's intentionally using deprecated functionality. This allows the tests to continue validating the deprecated class during its deprecation period.


19-24:

✅ Verification successful

Verify that the test coverage aligns with PostgreSQL documentation.

The test validates basic functionality of regexp_replace with a pattern, replacement, and flags, but could benefit from more comprehensive test cases that demonstrate various replacement scenarios.


🏁 Script executed:

#!/bin/bash
# Check if the test covers examples from PostgreSQL documentation
echo "Checking for comprehensive test coverage based on PostgreSQL examples..."

# Look for test cases for the non-deprecated RegexpReplace
rg -n "regexp_replace" tests/

Length of output: 2070


🏁 Script executed:

#!/bin/bash
sed -n '1,200p' tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplaceTest.php

Length of output: 994


No additional tests required for FlaggedRegexpReplace.

The suite already covers all major regexp_replace scenarios (basic replacement, flags, start position, occurrence count) in RegexpReplaceTest.php. The FlaggedRegexpReplaceTest.php exercise—passing a flags-only invocation—is consistent with its purpose and PostgreSQL behavior.
– Comprehensive flag/use‐case combinations live in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpReplaceTest.php
FlaggedRegexpReplaceTest.php correctly verifies the DQL function mapping with the flag argument only.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplace.php (1)

7-10: Appropriate deprecation notice with clear migration path.

The deprecation notice clearly indicates when this function will be removed and what alternative to use instead. This gives users time to migrate to the recommended RegexpReplace class before v4.0.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpLike.php (1)

8-10: Correctly marked as deprecated

The deprecation notice is clear and helpful, guiding users to use RegexpLike instead of this class. This aligns well with the PR objective of deprecating legacy limited flagged variations of regexp functions.

docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md (1)

85-87: Documentation simplification looks good

The documentation has been simplified by unifying regexp function entries without flag distinctions, which aligns with the code changes that consolidate these functions. This makes the documentation clearer and more maintainable.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

85-85: Table pipe style
Expected: leading_only; Actual: leading_and_trailing; Unexpected trailing pipe

(MD055, table-pipe-style)


86-86: Table pipe style
Expected: leading_only; Actual: leading_and_trailing; Unexpected trailing pipe

(MD055, table-pipe-style)


87-87: Table pipe style
Expected: leading_only; Actual: leading_and_trailing; Unexpected trailing pipe

(MD055, table-pipe-style)

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatch.php (4)

10-13: Documentation update enhances clarity

The updated description clearly explains what the function does and links to the latest PostgreSQL documentation. The reference to PostgreSQL 17 shows forward-thinking documentation practices.


17-18: Helpful usage example added

Adding an example of how to use the function in DQL is very helpful for developers. This kind of practical documentation makes the library more user-friendly.


19-29: Well-structured variadic function implementation

The class now extends BaseVariadicFunction and properly defines the node mapping patterns for different argument combinations. The implementation supports various argument patterns in a clean and maintainable way.


36-44: Proper argument count constraints

The implementation correctly defines the minimum (2) and maximum (4) argument counts, which aligns with PostgreSQL's regexp_match function capabilities. This provides clear boundaries for function usage.

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatchTest.php (5)

12-18: Good test class extension and fixture creation

Extending BaseVariadicFunctionTestCase is appropriate for testing the variadic functionality. The createFixture() method properly initializes the function for testing.


28-33: Comprehensive SQL test cases

The expected SQL statements cover all the supported patterns: basic match, with flags, with start position, and with both start position and flags. This ensures complete test coverage of the function's capabilities.


39-43: Well-structured DQL test statements

The DQL statements match the expected SQL statements and provide good test coverage for all supported argument patterns. Using ContainsTexts fixture makes the tests realistic.


46-53: Good validation test for minimum arguments

Testing that the function properly rejects calls with too few arguments ensures robust validation. The exception message is clear and matches the implementation's constraints.


55-62: Good validation test for maximum arguments

Testing that the function properly rejects calls with too many arguments completes the boundary testing. The exception message correctly communicates the acceptable argument range.

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLikeTest.php (6)

7-9: Appropriate imports for new base class and exception.

Good additions. The imports correctly reflect the new class inheritance and exception handling for argument validation tests.


12-18: Base class change and fixture setup properly implemented.

The test class now correctly extends BaseVariadicFunctionTestCase instead of TestCase, which aligns with the implementation change. The new createFixture() method properly instantiates the RegexpLike class as a BaseVariadicFunction.


28-32: Well-structured test cases for SQL statements.

The test cases are now well-organized with descriptive keys and cover all the function variations according to PostgreSQL documentation:

  • Basic 2-parameter usage
  • With flags (3 parameters)
  • With start position (3 parameters)
  • With both start position and flags (4 parameters)

This provides comprehensive coverage of all valid parameter combinations.


38-42: Matching DQL statements for all parameter combinations.

The DQL statements correctly match the expected SQL output and cover all supported parameter combinations. The use of sprintf with the entity class name is a good practice for maintaining test flexibility.


46-53: Good exception testing for insufficient arguments.

This test appropriately verifies that the function throws the correct exception with a meaningful message when called with fewer than the required minimum of 2 arguments.


55-62: Good exception testing for excessive arguments.

This test properly validates that the function throws an exception when called with more than the maximum allowed 4 arguments. The error message is clear and helpful.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpLike.php (4)

7-18: Improved documentation with clear examples.

The enhanced PHPDoc provides a more descriptive explanation of the function's behavior, includes an updated link to PostgreSQL 17 documentation, and adds a helpful example of usage in DQL. This makes the function more maintainable and easier to use.


19-20: Appropriate base class change for variadic support.

Changing from BaseRegexpFunction to BaseVariadicFunction correctly implements the support for variable argument counts (2-4) as intended in this PR.


21-29: Well-defined node mapping patterns for all parameter combinations.

The implementation provides mapping patterns for all valid parameter combinations:

  • Basic 2-parameter usage: string, pattern
  • 3-parameter with flags: string, pattern, flags
  • 3-parameter with start position: string, pattern, position
  • 4-parameter with both: string, pattern, position, flags

This correctly implements the PostgreSQL REGEXP_LIKE function's parameter variations.


36-44: Proper argument count constraints.

The implementation correctly defines:

  • Minimum argument count: 2 (string to search, pattern)
  • Maximum argument count: 4 (string, pattern, position, flags)

These constraints match PostgreSQL's function signature and are properly enforced by the base class.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 22, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 22, 2025
@martin-georgiev martin-georgiev changed the title feat: extend support of REGEXP_LIKE() and REGEXP_MATCH() while deprecating the legacy limited flagged variations of FlaggedRegexpLike, FlaggedRegexpMatch and FlaggedRegexpReplace feat: extend support of REGEXP_LIKE(), REGEXP_MATCH() and REGEXP_REPLACE() while deprecating the legacy limited flagged variations of FlaggedRegexpLike, FlaggedRegexpMatch and FlaggedRegexpReplace Apr 22, 2025
{
protected function customizeFunction(): void
{
$this->setFunctionPrototype('regexp_like(%s, %s, 1, %s)');
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually a bug that never worked as intended.

# Conflicts:
#	docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 22, 2025
@martin-georgiev martin-georgiev enabled auto-merge (squash) April 22, 2025 18:25
@martin-georgiev martin-georgiev merged commit ef688dc into main Apr 22, 2025
45 of 47 checks passed
@martin-georgiev martin-georgiev deleted the drop-flagged branch April 22, 2025 18:25
@github-actions github-actions bot mentioned this pull request Apr 22, 2025
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