Skip to content

Conversation

@martin-georgiev
Copy link
Owner

@martin-georgiev martin-georgiev commented Mar 28, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new exception for handling invalid JSONB array items, improving error messaging.
    • Enhanced test cases to validate various types of invalid JSON formats for better reliability.
  • Bug Fixes

    • Improved the validation process for JSONB array conversions, ensuring consistent and reliable error handling during data transformation.

@coderabbitai
Copy link

coderabbitai bot commented Mar 28, 2025

Walkthrough

This pull request introduces a new exception class, InvalidJsonbArrayItemForPHPException, to handle errors during JSONB array item conversion. It removes the obsolete TypeException and UnexpectedTypeOfTransformedPHPValue classes. The JsonbArray class now uses the new exception for handling invalid JSONB formats and types, and the tests have been updated accordingly with a new data provider to cover various invalid inputs.

Changes

File(s) Change Summary
src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/InvalidJsonbArrayItemForPHPException.php Added new exception class with methods: create, forInvalidType, and forInvalidFormat for handling invalid JSONB array items.
src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/TypeException.php
src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/UnexpectedTypeOfTransformedPHPValue.php
Removed obsolete exception classes used previously for type-related errors.
src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php Updated exception handling to throw InvalidJsonbArrayItemForPHPException directly; removed an unnecessary variable declaration.
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php Updated tests to expect the new exception; renamed the test method and added a data provider for invalid JSON inputs.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant JsonbArray
    participant ExceptionFactory

    Client->>JsonbArray: transformArrayItemForPHP(input)
    alt JSON decoding fails
        JsonbArray->>ExceptionFactory: forInvalidFormat(value)
        ExceptionFactory-->>JsonbArray: Exception instance
        JsonbArray->>Client: throw exception
    else Decoded value is not an array
        JsonbArray->>ExceptionFactory: forInvalidType(value)
        ExceptionFactory-->>JsonbArray: Exception instance
        JsonbArray->>Client: throw exception
    else Valid array obtained
        JsonbArray->>Client: return array
    end
Loading

Poem

I'm a rabbit, full of cheer, with code so neat and bright,
Hopping through exceptions, guiding errors to the light.
New checks bloom like flowers in the spring,
Old classes fade away as the new change rings.
With every hop, I celebrate this coding flight!
🐇💻✨


📜 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 e9a8ba3 and b2969c2.

📒 Files selected for processing (1)
  • tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + 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 plan to trigger planning for file edits and PR creation.
  • @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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ba3f9f2 and e9a8ba3.

📒 Files selected for processing (5)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/InvalidJsonbArrayItemForPHPException.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/TypeException.php (0 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/UnexpectedTypeOfTransformedPHPValue.php (0 hunks)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php (2 hunks)
  • tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php (2 hunks)
💤 Files with no reviewable changes (2)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/TypeException.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/UnexpectedTypeOfTransformedPHPValue.php
🧰 Additional context used
🧬 Code Definitions (1)
src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php (1)
src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/InvalidJsonbArrayItemForPHPException.php (3)
  • InvalidJsonbArrayItemForPHPException (9-25)
  • forInvalidType (16-19)
  • forInvalidFormat (21-24)
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 1.2
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.14 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM 3.0 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php

[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer latest
🔇 Additional comments (10)
src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php (4)

7-7: Import statement updated to use the new exception class

The import statement has been properly updated to use the new InvalidJsonbArrayItemForPHPException class, which is part of the refactoring to improve exception handling.


50-52: Improved exception handling for invalid types

The code now uses the specialized forInvalidType factory method from the new exception class, which provides more specific and descriptive error messages when a non-array JSON value is encountered.


54-54: Code simplification by returning directly

The code has been simplified by removing the unnecessary $transformedValue variable and returning the value directly, which reduces cognitive load while maintaining the same functionality.


55-57: Enhanced exception handling for invalid formats

The catch block now uses the specialized forInvalidFormat factory method from the new exception class, providing clearer error messages when JSON parsing fails due to format issues.

src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/InvalidJsonbArrayItemForPHPException.php (3)

9-14: Well-structured exception class with proper inheritance

The new exception class properly extends Doctrine's ConversionException and includes a private factory method for creating exception instances with formatted messages. This approach ensures consistent error message formatting.


16-19: Clear factory method for type validation errors

The forInvalidType method provides a clear, specific error message for invalid JSON types, making debugging easier by immediately showing what was actually received versus what was expected.


21-24: Specialized factory method for format validation errors

The forInvalidFormat method creates exceptions with clear error messages for invalid JSON format issues, improving the debugging experience when malformed JSON is encountered.

tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php (3)

8-8: Updated import to reference the new exception class

The import statement has been correctly updated to use the new InvalidJsonbArrayItemForPHPException class, which aligns with the refactoring changes.


93-98: Test method renamed and updated to use data provider

The test method has been renamed to better reflect its broader purpose and now accepts a parameter from the data provider, allowing for more comprehensive testing of different invalid JSON scenarios.


100-101: Updated exception assertions

The test now correctly expects the new exception class and message, ensuring proper validation of the error handling behavior.

@coveralls
Copy link

Coverage Status

coverage: 92.995% (-0.3%) from 93.284%
when pulling b2969c2 on jsonbarrexceptions
into ba3f9f2 on main.

@martin-georgiev martin-georgiev merged commit 0058d1c into main Mar 28, 2025
43 of 46 checks passed
@martin-georgiev martin-georgiev deleted the jsonbarrexceptions branch March 28, 2025 12:59
This was referenced Mar 28, 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.

3 participants